如果 sizeof(int) == sizeof(long),那么 INT_MIN == LONG_MIN && INT_MAX == LONG_MAX 总是 true 吗?
If sizeof(int) == sizeof(long), then is INT_MIN == LONG_MIN && INT_MAX == LONG_MAX always true?
如果 sizeof(int) == sizeof(long)
,那么 INT_MIN == LONG_MIN && INT_MAX == LONG_MAX
是否总是正确的?
是否有真实存在的案例证明“不真实”?
更新。类似问题:.
不一定是真的。 C11 6.2.6.2p2:
For signed integer types, the bits of the object representation shall be divided into three groups: value bits, padding bits, and the sign bit. There need not be any padding bits; signed char shall not have any padding bits.There shall be exactly one sign bit. Each bit that is a value bit shall have the same value as the same bit in the object representation of the corresponding unsigned type (if there are M value bits in the signed type and N in the unsigned type, then M <= N ). 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 -(2M) (two's complement);
- the sign bit has the value -(2M- 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.
现在,问题是“是否有任何实现具有不同数量的填充位”,或者,即使 ,不同类型整数的不同表示 - 很难证明存在目前没有这样的实施。但我相信在现实生活中很少有人会遇到这样的系统。
如果 sizeof(int) == sizeof(long)
,那么 INT_MIN == LONG_MIN && INT_MAX == LONG_MAX
是否总是正确的?
是否有真实存在的案例证明“不真实”?
更新。类似问题:
不一定是真的。 C11 6.2.6.2p2:
For signed integer types, the bits of the object representation shall be divided into three groups: value bits, padding bits, and the sign bit. There need not be any padding bits; signed char shall not have any padding bits.There shall be exactly one sign bit. Each bit that is a value bit shall have the same value as the same bit in the object representation of the corresponding unsigned type (if there are M value bits in the signed type and N in the unsigned type, then M <= N ). 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 -(2M) (two's complement);
- the sign bit has the value -(2M- 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.
现在,问题是“是否有任何实现具有不同数量的填充位”,或者,即使