As a Mathematician I would like:
S.
S at s.com
Fri Jun 29 17:00:03 PDT 2007
Stephen Montgomery-Smith Wrote:
> 2. a%b has a very definite and unambiguous meaning when a is negative,
> and b is positive. The output should be non-negative. This is something
> perl has done right. For example (-6)%7 is 1.
That's not true. There is two definitions of the 'mod' operator for negative numbers. Depends on how you define the operator itself.
-6%7 is equally 1 or -6.
Long division makes extensive use of remainders for calculations, if you were to say the initial calculation was 7*-1 remainder 1, then you would have a very wrong answer doing division by hand.
See: http://en.wikipedia.org/wiki/Modulo_operation
and http://mathforum.org/library/drmath/view/52343.html
More information about the Digitalmars-d
mailing list