From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <3e1162e60512170309kba53cefm6959ed5b62135f0d@mail.gmail.com> Date: Sat, 17 Dec 2005 03:09:23 -0800 From: David Leimbach To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] More Microsoft bashing In-Reply-To: <6e35c0620512152004n37c06ff5wd250424db50d874d@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1366_14048004.1134817763265" References: <6e35c0620512152004n37c06ff5wd250424db50d874d@mail.gmail.com> Topicbox-Message-UUID: c97b7418-ead0-11e9-9d60-3106f5b1d025 ------=_Part_1366_14048004.1134817763265 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline C's 'mod' isn't really mod. It's actually remainder. It's always been thi= s way to my knowledge. If you want a real "mod" use Python or Ada :) Dave On 12/15/05, Jack Johnson wrote: > > 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 > ------=_Part_1366_14048004.1134817763265 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline C's 'mod' isn't really mod.  It's actually remainder.  It's alway= s been this way to my knowledge.

If you want a real "mod" = use Python or Ada :)

Dave

On= 12/15/05,=20 Jack Johnson <knapjack@gmail.com> wrote:
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 Doc= ument on
the Common Language Infrastructure (CLI).

result =3D value1 DIV = value2 satisfies the following conditions:
|result| =3D |value1| / |valu= e2|, and
sign(result) =3D +, if sign(value1) =3D sign(value2)
sign(re= sult) =3D - , if sign(value1) # sign(value2)

result  =3D value1 MOD value2 satisfies the following con= ditions:
result =3D value1 - value2 * (value1 DIV value2), and
0 <= =3D |result| < |value2|, and
sign(result) =3D sign(value1)

Ple= ase 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 cr= acked
open The Nature of Computation by Pohl and Shaw, which yields:

  "x MOD y =3D x - (x =F7 y) * y, where =F7 indicate= s integer division (i.e.
fractions are disregarded; equivalently, the re= sult of the division is
truncated)."

So, what *is* -5 MOD 3?=

-Jack

------=_Part_1366_14048004.1134817763265--