Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site kontron.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!pyramid!nsc!voder!kontron!cramer From: cramer@kontron.UUCP (Clayton Cramer) Newsgroups: net.lang Subject: Re: Integer division Message-ID: <576@kontron.UUCP> Date: Wed, 5-Mar-86 18:11:16 EST Article-I.D.: kontron.576 Posted: Wed Mar 5 18:11:16 1986 Date-Received: Sat, 8-Mar-86 03:05:38 EST References: <11603@ucbvax.BERKELEY.EDU> <4917@alice.UUCP> Organization: Kontron Electronics, Irvine, CA Lines: 31 > In article <736@abic.UUCP> jst@abic.UUCP (Shack Toms) writes: > >> In article <731@abic.UUCP> jst@abic.UUCP (Shack Toms) writes: > >> >However: One might use a%b<0 iff a<0 in an algorithm which printed > >> >the value of an integer in a given radix. The least significant > >> >digit of a in radix b would then be |a%b|. :-) > >> > >> So would |a|%b, and it works under either convention. :-) > > > >Except that |a| is not available for the full range of a. In > >particular, on a 16 bit computer |-32768| is not expressible. > > I don't know about you, but I'm too paranoid about the least negative > number to begin with. In fact, I try not to get close, if possible. > > Frankly, if it's a question of a language getting integer division done > correctly on -32767 to 32767 or getting it done incorrectly on -32768 > to 32767, I think there is no debate about which is preferable. Or, > to express my point in less prejudicial terms: in arguing A vs B in a > language, the question of what happens with the least negative number > is almost always irrelevant. > > ucbvax!brahms!weemba Matthew P Wiener/UCB Math Dept/Berkeley CA 94720 In my experience, people start caring about least negative numbers when they want to use these weird values in the form: #define CantHappenFlag -32768 so that they can test for absurd values. Instead, these people should be using enumerated types. (I will admit to doing things like this before some gave me a C book with enumerated types described in it.)