Integer division

Radford Neal radford at calgary.UUCP
Wed Feb 5 10:16:02 AEST 1986


First, let me say that I'm firmly in the (-3)%2 == 1, (-3)/2 == (-2) camp. 
This is normally what one wants.

There is one case, however, where the (-3)/2 == 3/(-2) == -(3/2) == -1 
identity is usefull - writing software floating point routines. I offer this
as a suggestion as to why the initial "mistake" was made. 

Now that we "all" have hardware floating point, can we change divide?

Actually, I'd be satisfied if people would at least *document* what their
divide operation does! (E.g. the MC68000 processor manual just says "the
division is done using signed arithmetic"...)

     Radford Neal



More information about the Comp.lang.c mailing list