[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (work2) now available
- From: Dirk Laurie <dirk.laurie@...>
- Date: Mon, 24 Mar 2014 12:07:09 +0200
2014-03-24 12:18 GMT+02:00 Bernd Eggink <monoped@sudrala.de>:
>> In Lua 5.2, a = math.max(1, 2) returned that same double.
>
>
> Thanks, I wasn't aware of that.
>
>
>> 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:
>>> debug.setmetatable(0,{__tostring = function(x) return ("%.14g"):format(x)
>>> end})
> OK, but I guess I rather replace "math.max(a, b)" by "a > b and a or b",
> which is less tricky, but about 4 times faster.
And works for strings too. Maybe just call it "max" then?