Matthew Saltzman wrote:
On Thu, 24 May 2007, Mike McCarty wrote:
[snip]
developed. In any case, I don't know of any modern machine that
doesn't represent negative integers in two's complement.
Reach into your pocket, and pull out your calculator.
Fair enough. I'll concede the point if you can name a
standard-conforming C compiler for my calculator.
You stated that you didn't know of any modern machine. I don't
know of any conforming implementations. Most calculators use
decimal floating point or decimal fixed point. A conforming
implementation would be difficult, since a pure binary representation
is required for integral types.
H&S note that sign-magnitude and one's complement are permitted, but the
Any pure binary representation will do.
Usenet discussions involved subtle arguments that are long lost to (my)
memory (as is the final conclusion). For most of us programming modern
general-purpose computers, it's a moot point.
H&S also state in an example that
unsigned u;
if ( u > -1 ) ...
will never execute the if block (because -1 is cast to unsigned before
the comparison). But that's not true for sign-magnitude.
I'd have to go back and read the standard promotion rules before
commenting on this one.
Erm, from the Standard:
3.4
[#1] byte
addressable unit of data storage large enough to hold any
member of the basic character set of the execution
environment
OK that was from memory (and at 3am, to boot). From H&S, a "byte" or
"storage unit" is as above, essentially, the smallest independently
addressible block of storage. The char type has a size of one byte. (As
I recall, whether a standard-conforming compiler could be written for a
word-addressible machine was also a subject of language-lawyer debates
on Usenet.)
The Standard does not say what size a byte is. CHAR_BIT defines that.
It is possible for a conforming implementation to have CHAR_BIT to
be 64. A byte does not have to be the smallest independently addressable
unit greater than a bit on the underlying architecture, but it does have
to be the smallest unit to which the implementation provides
addressability which is greater than a bit.
Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
Oppose globalization and One World Governments like the UN.
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!