From: David Leimbach <leimy2k@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] More Microsoft bashing
Date: Sat, 17 Dec 2005 03:24:10 -0800 [thread overview]
Message-ID: <3e1162e60512170324jaf33d6cgf5938e68e92256d2@mail.gmail.com> (raw)
In-Reply-To: <3e1162e60512170309kba53cefm6959ed5b62135f0d@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2466 bytes --]
If you have the C99 standard handy anyway, this is clearly stated on page 82
:)
6.5.5.5:
---
The result of the / operator is the quotient from the division of the first
operand by the second; the result of the % operator is the remainder. In
both operations, if the value of the second operand is zero, the behavior is
undefined.
---
So negatives are allowed in the C99 standard.
I don't have a copy of the C89 standard so I can't quote that one. Plan 9 C
isn't C99 so I'm not sure any of this is even relevant ot the list.
In The C Programming Language ["draft ANSI Version" that I got from a
college professor who was retiring] it says that the expression
x % y
produces the remainder when x is divided by y.
Dave
On 12/17/05, David Leimbach <leimy2k@gmail.com> wrote:
>
> C's 'mod' isn't really mod. It's actually remainder. It's always been
> this way to my knowledge.
>
> If you want a real "mod" use Python or Ada :)
>
> Dave
>
> On 12/15/05, 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 Document on
> > the Common Language Infrastructure (CLI).
> >
> > result = value1 DIV value2 satisfies the following conditions:
> > |result| = |value1| / |value2|, and
> > sign(result) = +, if sign(value1) = sign(value2)
> > sign(result) = - , if sign(value1) # sign(value2)
> >
> > result = value1 MOD value2 satisfies the following conditions:
> > result = value1 - value2 * (value1 DIV value2), and
> > 0 <= |result| < |value2|, and
> > sign(result) = 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 = (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)."
> >
> > So, what *is* -5 MOD 3?
> >
> > -Jack
> >
>
>
[-- Attachment #2: Type: text/html, Size: 3378 bytes --]
prev parent reply other threads:[~2005-12-17 11:24 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-16 4:04 Jack Johnson
2005-12-16 4:51 ` Dan Cross
2005-12-16 5:02 ` Dan Cross
2005-12-16 5:33 ` erik quanstrom
2005-12-16 5:38 ` Bruce Ellis
2005-12-16 10:46 ` Charles Forsyth
2005-12-16 13:13 ` Dan Cross
2005-12-16 4:53 ` erik quanstrom
2005-12-16 5:08 ` Dan Cross
2005-12-16 5:19 ` Brian L. Stuart
2005-12-16 5:27 ` Bruce Ellis
2005-12-16 14:19 ` Brantley Coile
2005-12-16 15:13 ` Bruce Ellis
2005-12-16 15:29 ` Russ Cox
2005-12-16 16:00 ` Bruce Ellis
2005-12-17 0:26 ` Jack Johnson
2005-12-17 3:59 ` Bruce Ellis
2005-12-16 15:33 ` Brantley Coile
2005-12-16 10:47 ` John Stalker
2005-12-16 14:25 ` Brantley Coile
2005-12-16 14:51 ` Gorka guardiola
2005-12-16 22:28 ` Victor Nazarov
2005-12-17 11:09 ` David Leimbach
2005-12-17 11:24 ` David Leimbach [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3e1162e60512170324jaf33d6cgf5938e68e92256d2@mail.gmail.com \
--to=leimy2k@gmail.com \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).