lua-users home
lua-l archive

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

Grellier, Thierry wrote:
> Well, I find it weak defense to say that manual doesn't claim
> consistency (one may then consider this a manual issue).

Umm, I guess you've not been on the list back then ... math.mod
was there before %. It's also clearly marked as a compatibility
function (renamed to math.fmod). Which btw is the main reason why
the behaviour is different and why two variants are required.

The manual is pretty consistent with the implementation:

"[The] Modulo [operator] 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."

"math.fmod (x, y) -- Returns the remainder of the division of x by y."