From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom To: 9fans@cse.psu.edu, Jack Johnson References: <6e35c0620512152004n37c06ff5wd250424db50d874d@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 In-Reply-To: <6e35c0620512152004n37c06ff5wd250424db50d874d@mail.gmail.com> Subject: [9fans] More Microsoft bashing Message-Id: <20051216045306.126521B12F3@dexter-peak.quanstro.net> Date: Thu, 15 Dec 2005 22:53:06 -0600 Cc: Topicbox-Message-UUID: c8dfcc8e-ead0-11e9-9d60-3106f5b1d025 these can be shown to be the same: Jack Johnson 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