"bartek" <> wrote in message news:Xns9487E4C48EE9Cbartekdqwertyuiopo2p@153.19.2 51.200...
>
> Would the following code snippet result in '0' being displayed on all
> implementations?
>
> unsigned x(std::numeric_limits<unsigned>::max());
> std::cout << ++x << std::endl;
>
Yes, It is required that unsigned variables roll over from their max value to zero.
3.9.1/4
Unsigned integers, declared unsigned, shall obey the laws of arithmetic modulo 2n where n is the number
of bits in the value representation of that particular size of integer.
|