lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> On Sun, Aug 26, 2018 at 2:05 PM, Dirk Laurie wrote:
> 
> > the correct value ... that Lua 5.3 returns.
> >
> >
> Indeed, fmod() is doing its job very well.
> IMO, fmod() does worth its performance price.

Going down all the way, the multiplication used in 5.3 to test
the sign of the result may underflow:

$ Lua 5.3.2  Copyright (C) 1994-2015 Lua.org, PUC-Rio
> -2.1^-1000 % 2^-1000
-5.928787750095e-323

The result should be non negative, in the range [0,2^-1000). It is
better to use explicit tests:

    /* m is not zero and m and b have different signs */
    if ((m) < 0 && ((m) < 0) != ((b) < 0)) (m) += (b);

-- Roberto