Something IBM did right (RT division of negatives).
Stuart Gathman
stuart at bms-at.UUCP
Wed Nov 9 02:44:03 AEST 1988
In article <11529 at bellcore.bellcore.com>, sjs at jcricket.ctt.bellcore.com (Stan Switzer) writes:
> Anyone wishing to take up the other side of the argument must find an
> example of an actual situation where having -1/2 yield -1 is useful.
How about rounding by adding 1/2 and truncating (toward the smallest number,
not zero)?
Trunctating (-1)/2 to -1 is exactly the approach that does *not* require
checking the sign when using arithmetic shifts. If you want logical
shifts, use unsigned operands.
--
Stuart D. Gathman <stuart at bms-at.uucp>
<..!{vrdxhq|daitc}!bms-at!stuart>
More information about the Comp.lang.c
mailing list