Basic Math Problem.. 1 divided by 2

Blitz3D Forums/Blitz3D Beginners Area/Basic Math Problem.. 1 divided by 2

BlackD(Posted 2004) [#1]
n#=1/2
Print n#

On my comp, this is producing 0.0
Shouldn't it produce 0.5? WTF? :)

+BlackD


mongia2(Posted 2004) [#2]
1.0/2

or 1/2.0


BlackD(Posted 2004) [#3]
dividing to a floating point below zero only works if the input variables are floating points?

News to me. Never figured that.. since n#=10/2 gives 5..

/me recodes half the friggin game so the delta timing is perfect...


Réno(Posted 2004) [#4]
n#=(10/2) gives 5 ( returns an integer )
n#=(10.0/2.0) gives 5.0 ( returns a float )


big10p(Posted 2004) [#5]
Yeah, this is happening because the 1/2 calculation is done before the result is stored in n#. Since the calculation only involves integers, the result is integer which is then converted to float and stored in n#.