James said:
Philip Potter wrote:
...
That is debatable, and has been debated on comp.std.c. Not that I
disagree; I was arguing your side in that debate. However, the other
side interpreted the wording of the standard as allowing the
representation that would otherwise represent negative zero to be a trap
representation, but permitting no other trap representations.
I was arguing that it is permitted for an implementation to declare a 32
bit int type to have INT_MIN = -32768 and INT_MAX=2147483647, by
treating all bit patterns that would otherwise represent values from
-2147483648 to -32769 to be trap representations. This would break a lot
of existing code, and I doubt that this was the committee's intent, but
I don't see it as violating any actual requirements in the standard.
I can't see how there could be any debate, at least as far as n1256 is
concerned. From 6.2.6.2p2:
"Which of these [sign-magnitude, 1's-comp or 2's-comp] applies is
implementation-defined, as is whether the value with sign bit 1 and all
value bits zero (for the first two), or with sign bit and all value bits
1 (for ones’ complement), is a trap representation or a normal value. In
the case of sign and magnitude and ones’ complement, if this
representation is a normal value it is called a negative zero."
"If the sign bit is zero, it shall not affect the resulting value. If
the sign bit is one, the value shall be modified in one of the following
ways:
— the corresponding value with sign bit 0 is negated (sign and magnitude);
— the sign bit has the value -(2N) (two’s complement);
— the sign bit has the value -(2N - 1) (ones’ complement).
Which of these applies is implementation-defined, as is whether the
value with sign bit 1 and all value bits zero (for the first two), or
with sign bit and all value bits 1 (for ones’ complement), is a trap
representation or a normal value. In the case of sign and magnitude and
ones’ complement, if this representation is a normal value it is called
a negative zero."
It seems quite clear that binary 10000000 is a possible trap
representation for signed char under twos complement.
Phil