Oxygen Basic
Programming => Bugs & Feature Requests => Topic started by: Brian Alvarez on May 22, 2019, 03:58:59 PM
-
Hello Charles, I found something weird, please take a look at this:
FUNCTION SFUNC1(byval long v1) as quad
if (v1 = 3434222111) then
print "SUCCESS" chr(13, 10)
ELSE
print "FAILURE" chr(13, 10)
end if
end function
FUNCTION SFUNC2(byval quad v1) as quad
if (v1 = 3434222111) then
print "SUCCESS" chr(13, 10)
ELSE
print "FAILURE" chr(13, 10)
end if
end function
SFUNC1(3434222111)
SFUNC2(3434222111)
This is supposed to return:
FAILURE
SUCCESS
but returns:
SUCCESS
FAILURE
Am i wrong?
-
In these, it should be all SUCCESS, but in SFUNC4 not explicitly stating BYVAL makes it fail and in SFUNC5, passing a second parameter makes it fail...
FUNCTION SFUNC4(byval quad v1) as quad
if (v1 = 3434234233) then
print "SUCCESS" chr(13, 10)
ELSE
print "FAILURE" chr(13, 10)
end if
end function
FUNCTION SFUNC5(byval quad v1, v2) as quad
if (v1 = 3434234233) then
print "SUCCESS" chr(13, 10)
ELSE
print "FAILURE" chr(13, 10)
end if
end function
SFUNC4(3434234233)
SFUNC4(byval 3434234233)
SFUNC5(byval 3434234233, 2)
-
Hi Brian,
The limit for integer literals is currently 32 bits.
o2 may eventually adopt MSVCRT to handle all numeric inputs:
'http://www.cplusplus.com/reference/cstdio/scanf/
'http://www.cplusplus.com/reference/cstdio/sscanf/
uses corewin
quad q
char c[256]
c="3434234233"
sscanf(strptr(c), "%dll", @q)
print c chr(13,10) q
-
Charles, does this mean passing integers as a quad parameter? is there any other limitation regarding this?
Because as far as i know, 3434234233 does not overflow a 32 bit value.... i looked at my code and it already
handles big integers nicely, but taking "big" a number exceeding 4294967295.
Also taking in account that it works with 1 parameter but fails with two, tells me there may be something else
in this... specially because this works:
quad v = 0
SFUNC5(v+3434234233)
While this:
FUNCTION SFUNC5(quad v1, v2) as quad
if (v1 = 3434234233) then
print "SUCCESS" chr(13, 10)
ELSE
print "FAILURE" chr(13, 10)
end if
end function
quad v = 0
SFUNC5(v+3434234233, v)
Complains about this:
ERROR: parameters mismatch for procedure sfunc5
params given : #long@_
OPTIONS:
sfunc5(quad,quad) returns quad
And this fixes all:
SFUNC5(quad (3434234233), quad 2+2)
Another question: Is there a chance to support BYCOPY with big numbers so that Oxygen creates a temporary
quad variable to pass it as a non-literal number? currently this appears to have no effect... so, i will temporarily
use quad as some sort of bycopy.
-
The hack worked. Now MOD, AND and other operators work fine with quads, floats and big literal numbers.
-
Your example works correctly on my new o2:
FUNCTION SFUNC5(quad v1, v2) as quad
if (v1 = 3434234233) then
print "SUCCESS" chr(13, 10)
ELSE
print "FAILURE" chr(13, 10)
end if
end function
quad v = 0
SFUNC5(v+3434234233, v)
bycopy is supported, but unnecessary for numeric primitives passed directly.
PS:
I've been able to extend number literals into the quad range directly, so this will go into the o2 update. :)