Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.lang.c Subject: Re: int divided by unsigned. Message-ID: <13944@lanl.gov> Date: 18 Jun 89 20:30:35 GMT References: <748@sdrc.UUCP> Distribution: na Organization: Los Alamos National Laboratory Lines: 22 From article <748@sdrc.UUCP>, by scjones@sdrc.UUCP (Larry Jones): > [...] > Well, there're two good reasons why you DON'T want to promote to > long: long might well be the same size as int and, if it's not, > it may well take a lot longer to compute the answer. In the > first case, you get an answer which is no more useful than the > unsigned version, [... This is not true. If long is the same as int, then I would at least get signed arithmetic performed. So, in my original example, -5/1000 would equal 0. In fact, 'promoting' unsigned to int would be better than the other way around. Since most arithmetic is not carried out on "large" numbers, promoting to int would produce expected results more often than the other way around. > ...] in the second case you violate the Spirit of C > by doing non-obvious things behind the programmer's back. But you are _already_ doing that by casting everything to unsigned! The point of my submission was that -5/1000 == bignumber _IS_ a non- obvious thing. The point is that the default 'promotion' order is has been poorly defined.