Maths errors
BlitzMax Forums/BlitzMax Programming/Maths errors
| ||
Consider the following code:Local a,b,c a=64 b=a^2 c=a*a If b=c Print "All ok!" Else Print "WTF?!" EndIf If I compile and run, b!=c (in fact, b is 4095 whereas c is 4096). If I modify the code as such Local a:Float,b:Float,c:Float a=64 b=a^2 c=a*a If b=c Print "All ok!" Else Print "WTF?!" EndIf all is well. If this some sort of integer or type coersion bug? Neil |
| ||
^ returns a floating point number, not an integer so floating point precision is failing you in this example. You could of course do: Local a:Int,b:Int,c:Int a=64 b=Ceil(a^2) c = a * a If b=c Print "All ok!" Else Print "WTF?!" EndIf |