[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Integers-related trap in Lua 5.3
- From: Egor Skriptunoff <egor.skriptunoff@...>
- Date: Fri, 20 May 2016 03:15:00 +0300
It is obvious that for any string representing an integer from (-2^63)
to (2^63-1) it is guaranteed that no integer overflow will happen
during all steps of the calculation.
So, if integer overflow occurs, then we are discarding integer result
and switching to calculation of float result.
It is possible that it may be more convenient to avoid checking of
integer overflow flag on every step of calculations.
We can simply calculate the value of the number two times:
as integer and as float.
When we calculating integer value, we ignore integer overflows.
When we calculating float value, the result saturates at infinity.
After that we compare both results.
delta = abs(float_value - integer_value)