2 / 3 = 0 ?

Monkey Forums/Monkey Programming/2 / 3 = 0 ?

Paul - Taiphoz(Posted 2013) [#1]
ok having a bit of a blonde moment. what am I doing wrong here or why am I expecting something that I am not getting.

Local a:float = 0
a = 2 / 3
Print "2/3 = " + Float(a)

Expecting 0.6 but getting 0


Paul - Taiphoz(Posted 2013) [#2]
wait do I need to typecast those two numbers as floats as well ?

Yes I do DOH!..


ziggy(Posted 2013) [#3]
Yes. Int(2/3) is 0
Also, the division of two Ints is an Int. You can solve it:
a = 2.0 / 3.0


dragon(Posted 2013) [#4]
try

a = 2 / 3.0