these can be shown to be the same:
Jack Johnson <[EMAIL PROTECTED]> writes
| result = value1 MOD value2 satisfies the following conditions:
| result = value1 - value2 * (value1 DIV value2), and
| 0 <= |result| < |value2|, and
| sign(result) = sign(value1)
but subsituting with wirth's eqn:
r = x MOD y
thus
(x MOD y) = x - y*(x DIV y)
so
x = (x DIV y) + (x MOD y)
|
| Please note that this definition of DIV and MOD differs from the
| definition given in [M. Reiser, N. Wirth. Programming in Oberon. p.
| 36]:
| x = (x DIV y) * y + (x MOD y), and
| 0 <= (x MOD y) < y
|
| ( from http://www.bluebottle.ethz.ch/oberon.net/faq.html#ad_DivMod )
|
| ------
|
| I kind of collect random, older computer science texts, so I cracked
| open The Nature of Computation by Pohl and Shaw, which yields:
|
| "x MOD y = x - (x ÷ y) * y, where ÷ indicates integer division (i.e.
| fractions are disregarded; equivalently, the result of the division is
| truncated)."
uh, if you replace ÷ with DIV (since the definition is the same),
x MOD y = x - (x DIV y)*y
thus
x = (x DIV y) * y + (x MOD y)
|
| So, what *is* -5 MOD 3?
|
-2