int divided by unsigned.

der Mouse mouse at mcgill-vision.UUCP
Sat Jul 8 19:15:48 AEST 1989


In article <13959 at lanl.gov>, jlg at lanl.gov (Jim Giles) writes:
> 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 [...], for those of us to whom it is not obvious.

> In every other programming language I am familiar with, [...] 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.

Really?  As in 65500U / 6 giving -6 (sixteen bit ints)?[%]  Take your
pick, you get either that -100 / 10U giving 654.  These aren't
integers our code is working with; they're just approximations.  You're
bound to be able to find discrepancies, you just have your choice of
where you want them to show up.

[%] Yes, I know this obeys the inequality you gave above.  But somehow
    `least astonishment' seems to want something more like 10916. :-)

> But, as I say, C rarely obeys the principle of least astonishment.

Depends on how your astonishment sensor has been trained.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse at larry.mcrcim.mcgill.edu



More information about the Comp.lang.c mailing list