C++标准有规定无符号整型溢出要变成0吗如果一直把一个无符号整型加下去, 直到0xFFFFFFFF, 会不会有某些编译器不把它变回0而一直停在0xFFFFFFFF

解决方案 »

  1.   

    C++ 标准要求必须变为03.9.1(4): Unsigned integers, declared unsigned, shall obey the laws of
    arithmetic modulo 2^n where n is the number of bits in the value
    representation of that particular size of integerFootnote: This implies that unsigned arithmetic does not overflow
    because a result that cannot be represented by the resulting unsigned
    integer type is reduced modulo the number that is one greater than the
    largest value that can be represented by the resulting unsigned
    integer
    type.