This question is about what the C ++ standard imposes on a range of basic integer types. In the C ++ 17 standard, the point 6.9.1for basic types has a point 4where it says that:
Unsigned integers must obey the laws of arithmetic modulo 2^nwhere nis the number of bits in the representation of the value of this particular integer size.
In the C standard, he only says that if [0, max]is a range that can be represented as an unsigned integer, all operations outside this range are reduced modulo range + 1. He never says he range + 1should be power 2.
Does this quote from the C ++ standard mean that all unsigned integers have a range of the form [0, 2^n - 1]? Can we deduce from this point that all signed integers have a range of shape [-2^(n/2), 2^(n/2) - 1]?
I don't see anything in the standard that says this, but the previous quote from the standard seems to imply such things.
PS: This question is different from the one given here as a duplicate. The question is why the two standards are not applied in the standard. My question is what is in the actual standard.
source
share