Is this a bug??

Blitz3D Forums/Blitz3D Beginners Area/Is this a bug??

BioHazard(Posted 2005) [#1]
n#=1280/800
print n#
this returns 1.0 and it should be 1.6

To make this work correctly you have to do this...

n#=1280./800
print n#
this returns 1.6

you could also do this...
n#=1280.0/800.0
print n#
this returns 1.6

Just seems odd.


Warren(Posted 2005) [#2]
If both of the arguments are integers, the result will be an integer.


Sir Gak(Posted 2005) [#3]
WarrenM is correct. Even though the first statement n#=1280/800 gives 'n' as a floating point variable, both of the numerics are integer class, so Blitz does integer math on them, then converts the result to floating point. By putting the decimal point on at least one of the numerics, you are telling Blitz to do both numbers as floating point, and then store the result in the n#.

BTW, if you did n=1280.00/800, noticing that 'n' is now an integer variable, Blitz will do the numerics as floating point, and then convert the result to the nearest integer result. The above gives an answer of 2 (not 1.6).