Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site abic.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!cwruecmp!abic!jst From: jst@abic.UUCP (Shack Toms) Newsgroups: net.lang Subject: Re: Integer division Message-ID: <752@abic.UUCP> Date: Fri, 7-Mar-86 18:07:40 EST Article-I.D.: abic.752 Posted: Fri Mar 7 18:07:40 1986 Date-Received: Sat, 8-Mar-86 23:49:23 EST References: <11603@ucbvax.BERKELEY.EDU> <4917@alice.UUCP> Organization: Allen-Bradley Co., Highland Heights, OH 44143 Lines: 40 > > 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.) In my experience, people care about least negative numbers any time they define a function which requires an integer argument which can meaningfully be from the full range. This could be anything from a random number generator (which requires a seed) to an integer modulus function :-). I don't believe I have ever used them as a CantHappenFlag, it is generally too easy to come across them as the result of ordinary computation. Shack Toms