Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!sri-unix!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.arch Subject: Re: negative addresses (really unsigned arithmetic) Message-ID: <965@cresswell.quintus.UUCP> Date: 13 May 88 10:20:37 GMT References: <2393@uvacs.CS.VIRGINIA.EDU> <9485@apple.Apple.Com> <11571@ut-sally.UUCP> Organization: Quintus Computer Systems, Mountain View, CA Lines: 45 In article <11571@ut-sally.UUCP>, nather@ut-sally.UUCP (Ed Nather) writes: > In article <9485@apple.Apple.Com>, bcase@Apple.COM (Brian Case) writes: > > In article <2393@uvacs.CS.VIRGINIA.EDU> wulf@uvacs.CS.VIRGINIA.EDU (Bill Wulf) writes: > > >...as far as I can tell, the primary (only?) use > > >of unsigned arithmetic is for address computations. > > Yeah, same here, unless it's for some obscure purpose or is supported > > directly by the source language. > > Your CS background is showing, gentlemen. When I gather data from stars, I > count the precious photons one at a time, and use unsigned arithmetic to > massage them, since there are no negative photons (unlike negative addresses). Ah, backgrounds. "unsigned" arithmetic is NOT the same as "arithmetic on natural numbers" (N as opposed to Z). What it means is "modulo 2^N, _sort of_". I don't imagine that Ed Nather likes it when his counts silently wrap around from 65535 to 0, but that's "unsigned" arithmetic for you. While I agree that it is useful to distinguish counts from other types, I'm not convinced that this is an argument for having a machine support "unsigned" arithmetic. If you have two counters, what could be more natural than taking the difference? If I do unsigned int counter[2]; then counter[1] - counter[0] in C is an "unsigned" quantity, which ought to come as an extremely unpleasant shock to anyone who thought "unsigned" was good for counting. (1) ADA requires that the basic integer types are symmetric around 0 (with perhaps an additional negative value), so on a VAX you can declare a subtype 0..16#7fff_ffff# but that's as far as it goes. Perhaps Bill Wulf could explain that the WM is meant for ADA? (2) I am getting sick of computers which cannot do integer arithmetic and won't admit their mistakes. Floating-point was bad enough, but when a computer will add 1 to a positive number and give me a negative number it's time we cleaned up our act. I use C every day, but it is an antique, and enforces too many mistakes from the past (such as running with integer exceptions disabled). (3) Why should the machine's wordsize show through into a programming language? It's fair enough for there to be a threshold (the register width) below which arithmetic is fast, but if I am willing to declare the ranges of my variables, why shouldn't the compiler handle whatever size I specify? So my vote is unsigned arithmetic, no; support for (compiler-generated) multi-precision operations, yes.