Basic Math Problem.. 1 divided by 2
Blitz3D Forums/Blitz3D Beginners Area/Basic Math Problem.. 1 divided by 2
| ||
n#=1/2 Print n# On my comp, this is producing 0.0 Shouldn't it produce 0.5? WTF? :) +BlackD |
| ||
1.0/2 or 1/2.0 |
| ||
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... |
| ||
n#=(10/2) gives 5 ( returns an integer ) n#=(10.0/2.0) gives 5.0 ( returns a float ) |
| ||
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#. |