[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [Bug] math.mod behaves differently than the modulus operator.
- From: Daniel Stephens <daniel@...>
- Date: Sat, 26 Jan 2008 15:39:45 -0800
Tom Barta wrote:
They have different behaviors for values where the sign of the value is
different from the divisor, each can be more or less useful in different
situations depending on your needs.
On Jan 26, 2008 4:29 PM, Luiz Henrique de Figueiredo
Please don't cry BUG when you see something you don't expect.
Out of curiosity, is there any explicit reason for math.mod() behaving
differently than the modulus operator (%)? It seems counterintuitive
that they behave differently (despite the lack of a formal guarantee
by the manual), but maybe I'm overlooking some case where the
distinction is worthwhile.
For example, Lua's choice of implementation guarantees that a % b == (a
+ N * b) % b for all integer N, whereas math.mod does not.