This question is about what the C++ standard imposes to the range of the fundamental integer types. In the C++17 standard, the point 6.9.1
on fundamental types has a point 4
where it says that:
Unsigned integers shall obey to the laws of arithmetic modulo
2^n
wheren
is the number of bits in the value representation of that particular size of integer.
In the C standard, it only says that if [0, max]
is the range that can be represented by an unsigned integer, all operations that goes out of this range is reduced modulo range + 1
. It never says that range + 1
should be a power of 2.
Does this quote of the C++ standard means that all unsigned integers have a range of the kind [0, 2^n - 1]
? Can we infer from that point that all signed integers have a range of the form [-2^(n/2), 2^(n/2) - 1]
?
I see nothing in the standard that say that, but the previous quote of the standard seems to imply that kind of things.
PS: This question is different from the one which is given here as a duplicate. The question linked is about why two's complement is not enforced in the standard. My question is about what is in the actual standard.