No way to convert float to integer??

Started by Millenium7, October 03, 2024, 05:39:21 AM

Previous topic - Next topic

Millenium7

I can't figure this out, there seems to be no way to convert a float to an integer
Documentation says that Math::Floor as well as Math::Round should return an integer, but they do not

Test code that shows all 3 values are returned as type 'real'. So how do I convert a to an integer to be able to use certain math operations correctly (i.e. modulus operator)

a = 12.34;
b = Math::Floor(a);
c = Math::Round(a,0);

println(a);
println(b);
println(c);

println(typeof(a));
println(typeof(b));
println(typeof(c));

Filipp Sudanov

You can do type conversion this way:

b = Math::Floor(12.34);
b = int32(a); println(typeof(b), b);
b = int64(a); println(typeof(b), b);
b = uint32(a); println(typeof(b), b);
b = uint64(a); println(typeof(b), b);
b = real(a); println(typeof(b), b);
b = boolean(a); println(typeof(b), b);