From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <6e35c0620512152004n37c06ff5wd250424db50d874d@mail.gmail.com> Date: Thu, 15 Dec 2005 20:04:02 -0800 From: Jack Johnson To: 9fans <9fans@cse.psu.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: [9fans] More Microsoft bashing Topicbox-Message-UUID: c89f3368-ead0-11e9-9d60-3106f5b1d025 Not really, but all the talk about Singularity got me poking around and I came across this: ------ How are the functions DIV and MOD defined? The following answers are given by the Internal Working Document on the Common Language Infrastructure (CLI). result =3D value1 DIV value2 satisfies the following conditions: |result| =3D |value1| / |value2|, and sign(result) =3D +, if sign(value1) =3D sign(value2) sign(result) =3D - , if sign(value1) # sign(value2) result =3D value1 MOD value2 satisfies the following conditions: result =3D value1 - value2 * (value1 DIV value2), and 0 <=3D |result| < |value2|, and sign(result) =3D sign(value1) 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 =3D (x DIV y) * y + (x MOD y), and 0 <=3D (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 =3D x - (x =F7 y) * y, where =F7 indicates integer division (i.e= . fractions are disregarded; equivalently, the result of the division is truncated)." So, what *is* -5 MOD 3? -Jack