Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>-2147483648</code> is not a "number". C++ language does not support negative literal values.</p> <p><code>-2147483648</code> is actually an expression: a positive literal value <code>2147483648</code> with unary <code>-</code> operator in front of it. Value <code>2147483648</code> is apparently too large for the positive side of <code>int</code> range on your platform. If type <code>long int</code> had greater range on your platform, the compiler would have to automatically assume that <code>2147483648</code> has <code>long int</code> type. (In C++11 the compiler would also have to consider <code>long long int</code> type.) This would make the compiler to evaluate <code>-2147483648</code> in the domain of larger type and the result would be negative, as one would expect. </p> <p>However, apparently in your case the range of <code>long int</code> is the same as range of <code>int</code>, and in general there's no integer type with greater range than <code>int</code> on your platform. This formally means that positive constant <code>2147483648</code> overflows all available signed integer types, which in turn means that the behavior of your program is undefined. (It is a bit strange that the language specification opts for undefined behavior in such cases, instead of requiring a diagnostic message, but that's the way it is.)</p> <p>In practice, taking into account that the behavior is undefined, <code>2147483648</code> might get interpreted as some implementation-dependent negative value which happens to turn positive after having unary <code>-</code> applied to it. Alternatively, some implementations might decide to attempt using unsigned types to represent the value (for example, in C89/90 compilers were required to use <code>unsigned long int</code>, but not in C99 or C++). Implementations are allowed to do anything, since the behavior is undefined anyway.</p> <p>As a side note, this is the reason why constants like <code>INT_MIN</code> are typically defined as</p> <pre><code>#define INT_MIN (-2147483647 - 1) </code></pre> <p>instead of the seemingly more straightforward </p> <pre><code>#define INT_MIN -2147483648 </code></pre> <p>The latter would not work as intended.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload