Article View: mod.std.c
Article #70mod.std.c Digest V5#7
From: Orlando Sotomayor-Diaz
Date: Sun, 21 Apr 1985 16:24
Date: Sun, 21 Apr 1985 16:24
75 lines
3055 bytes
3055 bytes
From: Orlando Sotomayor-Diaz (The Moderator) <cbosgd!std-c>
mod.std.c Digest Sun, 21 Apr 85 Volume 5 : Issue 7
Today's Topics:
#else JUNK
modulus, remainder, and %
----------------------------------------------------------------------
Date: Mon, 15 Apr 85 15:31:33 pst
From: nsc!turtlevax!ken@ihnp4.uucp (Ken Turkowski)
Subject: #else JUNK
To: ihnp4!cbosgd!mark@nsc.uucp
>A colleague of mine recently noted their sadness with the (November, 1984)
>draft standard's outlawing of source such as
> #ifdef VERBOSE
> printf("Hello, world.\n");
> #endif VERBOSE
>which, according to the draft, must have its last line changed to (for example)
> #endif /* VERBOSE */
>to be legal. Such code is now successfully dealt with on many systems.
The problem with this is that it removes the ability to structure pre-processor
directives. For example,
#ifdef VERBOSE
# ifdef DEBUG
# else !DEBUG
# endif DEBUG
#else !VERBOSE
#endif VERBOSE
Indicates clearly which #ifdef is ended with each #endif, regardless of the
fact that the stuff after the #else and #endif is ignored.
------------------------------
Date: Mon, 15 Apr 85 15:31:33 pst
From: nsc!turtlevax!ken@ihnp4.uucp (Ken Turkowski)
Subject: modulus, remainder, and %
To: ihnp4!cbosgd!mark@nsc.uucp
>The % operator is called the "mod" operator in C, but it does not compute
>modulus for signed numbers in any C implementation I know of. When I really
>want mod, I have to write (assuming b is unsigned):
>
> a%b>0?a%b:a%b+b
>
>Would it break anything to really define % as mod?
What's the problem? Both of them are equal (mod b). :->
Seriously, the % operator is defined as the remainder of a division such that:
(a / b) * b + (a % b) == a
Most implementations define the remainder to have the same sign as the
quotient, which has the property that:
(-a) / b == -(a / b)
Forcing the remainder to be positive would mean that quotient may be one less
than it is in most implementations. I think that the objection would not be
to defining % to yield a positive number, but to the change in the property
of quotients.
------------------------------
End of mod.std.c Digest - Sun, 21 Apr 85 11:19:48 EST
******************************
USENET -> posting only through cbosgd!std-c.
ARPA -> ... through cbosgd!std-c@BERKELEY.ARPA (NOT to INFO-C)
In all cases, you may also reply to the author(s) above.
Technical Details
Message-ID:
<900@homxa.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!homxa!osd7Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83 based; site homxa.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!homxa!osd7 From: osd7@homxa.UUCP (Orlando Sotomayor-Diaz) Newsgroups: mod.std.c Subject: mod.std.c Digest V5#7 Message-ID: <900@homxa.UUCP> Date: Sun, 21-Apr-85 11:24:25 EST Article-I.D.: homxa.900 Posted: Sun Apr 21 11:24:25 1985 Date-Received: Mon, 22-Apr-85 02:32:40 EST Organization: AT&T Bell Labs, Holmdel NJ Lines: 75 Approved: osd7@homxa.UUCP