10/3=3??!!

Blitz3D Forums/Blitz3D Programming/10/3=3??!!

ICECAP(Posted 2006) [#1]
Ohhh blitz is being a darling today. I have just finnished a lib for motionblur on any screen resolution and suddently i found errors... the source of the problem?
Apparently 10/3=3 and 0.1+0.1=0
Well, i thought it was just a case of me making the variables non integers... but no that didnt do anything.
Is this a problem with the latest version of blitz or am i missing something so stupidly simple?

The code i used to test this is below:

temp=10/3
print temp
waitkey()



WolRon(Posted 2006) [#2]
Common 'mistake'

Blitz is performing integer math and therefore returning an integer result (regardless of the variable type).

The solution: Just make any of the arguments involved a floating point number:

temp# = 10.0 / 3
temp# = 10 / 3.0
temp# = 10.0 / 3.0

or

temp# = float(10) / 3
temp# = 10 / float(3)
temp# = float(10) / float(3)


ICECAP(Posted 2006) [#3]
Well thats what i thought would fix it, but it still returns 3.

I am going to reinstall blitz and see if that fixes it.

If anyone else has a suggestion, please voice it coz its driving me mad!


ICECAP(Posted 2006) [#4]
Ha!!
Its the latest release of blitz.
I reinstalled and the problem was fixed.


WolRon(Posted 2006) [#5]
You reinstalled which version?


WolRon(Posted 2006) [#6]
Sorry, but I forgot to place the results of the operations above into Floating point variables. It's now corrected.


Ross C(Posted 2006) [#7]
.


Ice9(Posted 2006) [#8]
.


big10p(Posted 2006) [#9]
Why's everyone gone dotty?


ShadowTurtle(Posted 2006) [#10]
. and . means this:

temp = 10.0   /   3.0
print temp
waitkey()