N3797::3.9.1/1 [basic.fundamental]
说
For unsigned narrow character types, all possible bit patterns of the value representation represent numbers.
这对我来说有点不清楚。对于窄字符类型,我们有以下范围:
unsigned char := 0 -- 255
signed char : = -128 -- 127
对于 unsgined char
和 signed char
对象,我们有从这些对象表示中的位集到他们可以代表的整体值(value)。标准说 N3797::3.9.1/1 [basic.fundamental]
These requirements do not hold for other types.
为什么我引用的要求不适用于 signed char
类型?
最佳答案
有符号类型可以使用以下三种表示之一:二进制补码、个人补码或符号大小。最后两个各有一个位模式(零的否定),不代表数字。
补码是more or less现在对于整数类型是通用的;但语言仍然允许其他语言。
关于c++ - 无符号窄字符类型数字表示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26249221/