Smarter compiler?

Blitz3D Forums/Blitz3D Beginners Area/Smarter compiler?

Seldon(Posted 2004) [#1]
Is there a better way to do this ?

e#=1/2
DebugLog e# ;the compiler gives an integer result
Input ""
End

r1#=1
r2#=2
f#=r1#/r2#
DebugLog f# ;here the result is correct
Input ""
End



Zethrax(Posted 2004) [#2]
Should be:-

e#=1.0 / 2.0
DebugLog e# ;the compiler gives an integer result
Input ""
End


or

e#=Float#( 1 ) / Float#( 2 )
DebugLog e# ;the compiler gives an integer result
Input ""
End



Seldon(Posted 2004) [#3]
Thanks!


(tu) sinu(Posted 2004) [#4]
what it does, because the values passed are integer, is work out 1/2 and gives the result as an integer which is then given to e#, even though it is a float the value given is rounded.


Seldon(Posted 2004) [#5]
@sinu: ja, that I knew. But that isn't how most compilers work. :)