[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Number type limitations
- From: Vyacheslav Napadovsky <napadovskiy@...>
- Date: Tue, 5 Apr 2016 13:26:36 +0300
Hello.
Recently I faced a bug with some arithmetic. I suppose it is not Lua
related but PC architecture related. Nevertheless, I have a question
about how to avoid this behavior correctly.
I assume to check multiplicity with math.fmod() == 0.
> =math.fmod(235.7, 0.05)
0.049999999999976
> = 235.7 / 0.05
4714
> = 235.7 % 0.05
0.049999999999983
> = 235.7 - 235.7 / 0.05 * 0.05
2.8421709430404e-14
> =_VERSION
Lua 5.2
--
Vyacheslav Napadovsky