Integers instead of floating point

It would be very nice to be able to use true integers instead of floating points, since the latter is a pain. For example, the following code will never end because n1 will never equal zero (even though it should):

local n1 = 1
while n1 ~= 0 do
print(n1)
n1 = n1 - 0.01
end

This is just an example, not a practical situation, but it does point out the constant worry about what kind of weird behavior I will get from seemingly simple number manipulation. Is there a way to compile corona to use integers? [import]uid: 72609 topic_id: 17827 reply_id: 317827[/import]

Use math.floor, etc, you must understand what are you doing in your algorithm [import]uid: 65903 topic_id: 17827 reply_id: 68010[/import]

That’s what I’ve been doing, but it’s frankly ridiculous that such nonsense should be necessary. I know it’s a fact of life with lua, but Roberto says in his book that lua can be compiled to use integers instead of fp, and was wondering if perhaps corona could try this? [import]uid: 72609 topic_id: 17827 reply_id: 68015[/import]

i am afraid there is not. we can’t only have integers. space and time are continuous

decimal numbers are not exactly what they appear to be, and are followed by errors
in every programming language

do not compare an integer with a floating point. instead check that their difference is small, math.abs(floating-integer)<=error

[import]uid: 6459 topic_id: 17827 reply_id: 68022[/import]