这是 C 标准中整数类型符号位定义的错误吗?

Is this a mistake in the definition of the sign bit for integer types in the C standard?

我认为 ISO/IEC 9899:TC3 C standard

的第 6.2.6.2 节中描述整数类型的符号位有错误

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; 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 −(2^N) (two’s complement);
  • the sign bit has the value −(2^N − 1) (ones’ complement)

上一节定义N为有符号类型的值位数,这里为无符号类型的值位数

以每个字节 8 位和二进制补码的 signed char 为例,这表示符号位的值为 -(2^8) =-256 而不是 -(2^7) = -128.

我认为标准应该在开头的段落中切换 M 和 N 或更改符号位的定义以使用 M:

  • the sign bit has the value −(2^M) (two’s complement);
  • the sign bit has the value −(2^M − 1) (ones’ complement)

我是不是漏掉了什么,或者这是一个错误?

C11 draft standardJonathan Leffler 确认最终标准也包含此措辞)中确实从使用 N 切换到使用 M:

  • the sign bit has the value −(2M) (two’s complement);
  • the sign bit has the value −(2M − 1) (ones’ complement).

我找不到缺陷报告,但这取决于:

If there are N value bits

1 段也适用于第 2 段,这并不是一个不合理的解释,它只是高度含糊不清:

(if there are M value bits in the signed type and N in the unsigned type, then M <= N)