2 / 3 = 0 ?
Monkey Forums/Monkey Programming/2 / 3 = 0 ?
| ||
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 |
| ||
wait do I need to typecast those two numbers as floats as well ? Yes I do DOH!.. |
| ||
Yes. Int(2/3) is 0 Also, the division of two Ints is an Int. You can solve it: a = 2.0 / 3.0 |
| ||
try a = 2 / 3.0 |