[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [Bug] math.mod behaves differently than the modulus operator.
- From: Mike Pall <mikelu-0801@...>
- Date: Mon, 28 Jan 2008 13:20:12 +0100
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."