Integer division

Matthew P. Wiener weemba at brahms.BERKELEY.EDU
Wed Feb 19 19:26:34 AEST 1986


In article <736 at abic.UUCP> jst at abic.UUCP (Shack Toms) writes:
>> In article <731 at abic.UUCP> jst at 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.

>The real point [of the :-)] etc.
Agreed etc.

Personal to Shack Toms- I got mail asking me to keep this issue off
of net.arch.  As you reposted to net.arch, I wonder if you did?  As
it is, I'm sending this up to net.lang, since it is not really a C
specific question.

ucbvax!brahms!weemba	Matthew P Wiener/UCB Math Dept/Berkeley CA 94720



More information about the Comp.lang.c mailing list