Data type int's minimum value is -2,147,483,648.
So, I typed
int val = -2147483648;
But, it has an error:
unary minus operator applied to unsigned type.result still unsigned
How can I fix it?
2147483648 is out of int range on your platform.
Either use a type with more precision to represent the constant
int val = -2147483648L;
// or
int val = -2147483648LL;
(depending on which type has more precision than int on your platform).
Or resort to the good old - 1 trick
int val = -2147483647 - 1;
-2,147,483,648 is interpreted as negation of 2147483648. 2147483648 exceed maximum positive integer on your system and is considered as unsigned.
Instead, try
-2147483647 - 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With