Why does Visual Studio treats the constant
0x80000000) as unsigned?
From what I know this value is still within min limit for
Example, if you compile the following:
long a = -2147483648
The compiler will issue the following warning:
warning C4146: unary minus operator applied to unsigned type, result still unsigned type
It's because the decimal constant here is not
2147483648 with the unary
- operator applied to it. In C, numeric constants don't include signs.
2147483648 is out of range for
long on your implementation, so under the C89 rules this has type
unsigned long. Under the rules introduced in C99, it would instead have type
To change this code to produce the value -2147483648 with type
long, you can use:
long l = -2147483647 - 1;
Thats because maximum signed long could be 7FFFFFFF = 0111 1111 1111 1111 1111 1111 1111 1111.