Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!bloom-beacon!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP (der Mouse) Newsgroups: comp.lang.c Subject: Re: int divided by unsigned. Message-ID: <1578@mcgill-vision.UUCP> Date: 8 Jul 89 09:15:48 GMT References: <18296@mimsy.UUCP> <13959@lanl.gov> Distribution: na Organization: McGill University, Montreal Lines: 33 In article <13959@lanl.gov>, jlg@lanl.gov (Jim Giles) writes: > From article <18296@mimsy.UUCP>, by chris@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@larry.mcrcim.mcgill.edu