2014-03-24 2:06 GMT+02:00 Bernd Eggink <monoped@sudrala.de>:
Is it really intended that
a = math.max(1, 2)
returns a = 2.0 (a float)? This change in behaviour, besides being very
counterintuitive, kills a lot of my modules which rely on tostring(a) giving
"2" (without a decimal part). It means that I would have to surround each
such operation with an ifloor() call, which is pretty ineffective and
annoying.
If that can't be changed, I'd suggest an addition of imin(), imax() and
iabs(), witch return integers.
In Lua 5.2, a = math.max(1, 2) returned that same double.
The change in behaviour is that a double with the integer value 2 gets
tostring-ed to "2.0", not to "2". You can restore the original behaviour thus:
$ lua53
Lua 5.3.0 (work2) Copyright (C) 1994-2014 Lua.org, PUC-Rio
math.max(1,2)
2.0
debug.setmetatable(0,{__tostring = function(x) return ("%.14g"):format(x) end})
0
math.max(1,2)
2