lua-users home
lua-l archive

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


> > Have a look at the Lua reference manual:
> >
> > 	Modulo is defined as
> >
> > 		a % b == a - math.floor(a/b)*b
> >
> > 	That is, it is the remainder of a division that rounds the
> > 	quotient towards minus infinity.
> 
> "Defined as" is not the same as "implemented as". [...]

Then have a look at the code (http://www.lua.org/source/5.1/luaconf.h.html):

  #define luai_nummod(a,b)        ((a) - floor((a)/(b))*(b))

As the problem seems to happen only in some platforms, there is a good
chance that something (floor itself?) is messing with the rounding mode.

-- Roberto