int divided by unsigned.
Jim Giles
jlg at lanl.gov
Wed Jun 28 08:36:08 AEST 1989
>From article <18296 at mimsy.UUCP>, by chris at mimsy.UUCP (Chris Torek):
> Instead of simply asserting `it is obvious that ...', you might explain
> why you feel that way, for those of us to whom it is not obvious.
In every other programming language I am familiar with, integer division
is guaranteed to produce a result which is smaller than (or equal to)
the numerator in absolute value. That is, you can count on the following
relation:
| a/b | <= | a |
Other languages which have unsigned either don't allow mixed mode at all
(like Modula I, II, etc) or they treat unsigned as inferior to inferior
to signed for automatic conversion. This later decision conforms to
intuition (ie. the relation above) more often than the procedure C uses.
But, as I say, C rarely obeys the principle of least astonishment.
More information about the Comp.lang.c
mailing list