[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Modulo operator produces incorrect results with negative operand(s).
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 9 Feb 2017 10:27:00 -0200
> 2017-02-09 15:02 GMT+02:00 Martin <email@example.com>:
> > Sadly (as I understand from similar discussions before) Lua
> > implementation is heavily linked with ANSI C and Roberto generally not
> > willing to introduce changes in logic that is different from ANSI C.
> Roberto might like to speak for himself on this, but IMHO the above
> comment oversimplifies his position.
As Viacheslav pointed out, the comment does not make sense here, as the
discussion started exactly because Lua *is* different from ANSI C in
this particular logic corner. Anyway...
First, the fact that the Lua implementation is heavily linked
with ANSI C does not imply at all that the Lua specification is
linked with ANSI C.
Second, anyone willing to discuss this subject should read the paper
mentioned by Doug ("The Euclidean Definition of the Functions div and
mod"). Unlike C, which currently uses the T-definition, Lua uses the
F-definition, which is one of the definitions that the paper argues to
be "superior to all other ones in regularity and useful mathematical