Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!ncar!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: int divided by unsigned. Message-ID: <18306@mimsy.UUCP> Date: 28 Jun 89 04:10:04 GMT References: <18296@mimsy.UUCP> <13959@lanl.gov> Distribution: na Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 39 In article <13959@lanl.gov> jlg@lanl.gov (Jim Giles) writes: >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 | Well, you can count on it in C, too, because in `unsigned a; int b; a/b' you have unsigned division, rather than integer division; I find this no more odd than the fact that `a/b' is sometimes integer division and sometimes floating point division. But maybe I am just used to it. >Other languages which have unsigned either don't allow mixed mode at all >(like Modula I, II, etc) This I dislike (purely as a matter of taste), although as long as there is a mechanism for explicit conversions, the language has not lost any abilities. >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. That depends on where you get your intuition. I never would have expected people to put up with traffic jams either---it seems intuitively obvious that people would agree to flexible work hours instead, at least in jobs that permit it (most `white collar' work). That is, arrive any time between 0600 and 1000---sort of an extended version of `flex time'. But maybe that has something to do with me getting up at 1800 one day, 2250 the next, and around 0200 the day after. . . . Anyway, I happen to like `sticky unsigned' operation, but as I say, perhaps I am just used to it. It seems to me that a C-like language with `sticky signed' operation would work as well, although the results of such mixed mode operations would astonish me for a while. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris