casting?
Monkey Forums/Monkey Programming/casting?
| ||
So I ran into the following.. local t:Float For Local i:=0 To 4 t = i/LOD Next t is supposed to be some value between 0->1 .. but its always zero because i is an int.. the division gives me an int back and assigns zero to the t variable. So.. I got around this by creating a temporary floating point i variable but I'm wondering if theres anything equivalent to a c++ cast in monkey? to deal with issues like these |
| ||
to cast just do thislocal i:Float local j:Int i=9.5 j=Int(i) its very easy :) |
| ||
svero - casting is done like so:t = Float(i)/LOD i is cast to a float, so the division then returns a float. |
| ||
Thanks.. I tried (Float)i but I guess you know the results :-) |
| ||
You can cast either side, too.t = i/Float(LOD) |