0

I'm trying to write a simple program, and one of the lines is

int num = -2147483648;

and I get a "Negative integral constant converted to unsigned type" error.

Even when I do

int num = 2147483648 * -1;

It is the same thing.

The variable num is an int and not an unsigned int, so what's going on?

TryinHard
  • 4,078
  • 3
  • 28
  • 54
codem
  • 9
  • 1
  • 4
    I remember this being asked before ([found it](http://stackoverflow.com/questions/14695118/2147483648-0-returns-true-in-c)), but it's the unary `-` operator applied to a (positive) integer literal that is too big for `int`. – chris Aug 24 '15 at 03:57
  • 1
    You may find [**this sample**](http://ideone.com/YiIUwx) interesting. It directly relates to the link chris posted. – WhozCraig Aug 24 '15 at 04:04

0 Answers0