I know the range of short
is from 32767
to -32768
on most systems. But when I try to assign 32787
I see something different.
#include <stdio.h>
int main ()
{
short int a;
a = 32787;
printf("%hi\n",a);
}
Output:
-32749
This value actually my value + minimum short value + minimum short value and not some random value. (32787 + (-32768)) + (-32768) = -32749
This is the first case I try to assign a high value to short int I will get warning from GCC I get some value.
This makes the results completely incomprehensible. Does anyone know what's going on here?