No way to convert float to integer??
-
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 notTest 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)); -
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);
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login