On Fri, May 10, 2019 at 5:08 PM Sean Conner wrote:
> But Lua *math* library is supposed to give mathematically correct results.
> math.abs(INT_MIN) should return correct (float) value.
> The similar issue has already been successfully solved in Lua: function
> *tonumber* returns result having most suitable numeric subtype.
Finally, quoting section 6.7 of the Lua manual:
This library provides basic mathematical functions. It provides all
its functions and constants inside the table math. Functions with
the annotation "integer/float" give integer results for integer
arguments and float results for float (or mixed) arguments. Rounding
functions (math.ceil, math.floor, and math.modf) return an integer
when the result fits in the range of an integer, or a float
otherwise.
math.abs(x)
Returns the absolute valud of x. (integer/float)
According to Lua manual, math.abs() must return the absolute value of its argument.
Obviously, math.abs(math.mininteger) not equals to the absolute value.
That's a bug.
"bug" means that behavior does not match documentation.
Either behavior should be changed (to return correct result)
or documentation should be changed (to claim math.abs as returning result modulo 2^64 instead of the correct result)