From: | fjh@cs.mu.OZ.AU (Fergus Henderson) |
Newsgroups: | comp.compilers |
Date: | 19 Nov 2000 20:27:50 -0500 |
Organization: | Computer Science, University of Melbourne |
References: | 00-11-046 00-11-082 00-11-120 00-11-122 |
Keywords: | modula, Pascal, types |
Posted-Date: | 19 Nov 2000 20:27:50 EST |
Jerry Leichter <jerrold.leichter@smarts.com> writes:
>There are two reasons for wanting an unsigned type:
>
> - To extend the range of small integers. This was very
> important in the days of 16-bit ints, and is almost
> certainly why unsigned ints were originally added
> to C. With 32 and now 64 bit ints the standard
> these days, this is rarely of any significance.
>
> - To implement "modulo arithmetic". Unsigned ints typically
> (and, by standard in C/C++) the mathematical properties
> of arithmetic mod 2^k. There are times when this is
> useful.
The trouble with just using a subtype for unsigned arithmetic is that
you lose one bit. Many of the most important uses of modulo
arithmetic are for the case where `k' is the word size. If your
language only provides 32-bit signed ints and subtypes thereof, and
you need 32-bit unsigned ints, then you're out of luck.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.