[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: What would you remove from Lua - a case of regression?
- From: Sean Conner <sean@...>
- Date: Mon, 26 Nov 2018 01:59:36 -0500
It was thus said that the Great Muh Muhten once stated:
> On 11/25/18, Philippe Verdy <verdy_p@wanadoo.fr> wrote:
> > Note: math.floor() is not required toi return a native binary integer. It
> > may return a variant type using integers for some ranges, and doubles
> > outside the range. So even in this case the the inference would not help
> > eliminate the necessary tests on the effective type of the variant... The
>
> math.floor can return literally anything. It can be redefined.
Of course, one could rewrite the function to remove the call to
math.floor() to apease the Great Pedantic One:
function fromjulianday(jd)
local a = jd + 32044
local b = (4 * a + 3) // 146097
local c = a - (b * 146097) // 4
local d = (4 * c + 3) // 1461
local e = c - (1461 * d) // 4
local m = (5 * e + 2) // 153
return {
day = e - (153 * m + 2) // 5 + 1,
month = m + 3 - 12 * (m // 10),
year = b * 100 + d - 4800 + (m // 10)
}
end
This is Lua 5.3 specific code where '//' is integer division.
-spc