Newsgroups: comp.arch Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: negative addresses (really unsigned arithmetic) Message-ID: <1988May22.020336.17472@utzoo.uucp> Organization: U of Toronto Zoology References: <2393@uvacs.CS.VIRGINIA.EDU> <9485@apple.Apple.Com> Date: Sun, 22 May 88 02:03:36 GMT > ... what are the "nasty surprises" > hiding in unsigned arithmetic that do not also exist for signed > arithmetic AS IT IS COMMONLY IMPLEMENTED IN HARDWARE? Well, for example, consider that a+b>c does not imply a>c-b in unsigned arithmetic. (To make this more obvious, consider that b>c does not imply c-b<0, since no unsigned number is less than zero.) Remember too that one unsigned number in a calculation tends to make the whole calculation be done unsigned, by C rules, sometimes unexpectedly. > Why should signed arithmetic be more efficient than unsigned? Because the hardware sometimes supports it rather better. On the machine I'm typing this on, for example, unsigned multiplication or division is significantly slower than the signed forms, because the hardware multiply and divide instructions are signed-only.