Copy codeThe Code is as follows: # include <stdio. h>
Int main (int argc, char * argv [])
{
Unsigned int max_int = 0-1;
Printf ("The max value of unsigned int on 32 machine: % u/n", max_int );
}
Copy codeThe Code is as follows: # include <stdio. h>
Int main (int argc, char * argv [])
{
Unsigned int max_int = 0-1;
Printf ("The max value of unsigned int on 32 machine: % u/n", max_int );
}
After gcc Compilation:
Int_sizeof1.c: In the 'main' function:
Int_sizeof1.c: 5: Warning: Integer Overflow
After running:
The max value of int on 32 machine: 4294967295
After VC6.0 and java are compiled, there is no error.
After running:
The max value of int on 32 machine: 4294967295Copy codeThe Code is as follows: # include <stdio. h>
Int main (int argc, char * argv [])
{
Int max_int = (1 <31)-1;
Printf ("The max value of int on 32 machine: % d/n", max_int );
}
The program that writes its int into a signed type is as follows:
Copy codeThe Code is as follows: # include <stdio. h>
Int main (int argc, char * argv [])
{
Int max_int = (1 <31)-1;
Printf ("The max value of int on 32 machine: % d/n", max_int );
}
After gcc Compilation:
Int_sizeof1.c: In the 'main' function:
Int_sizeof1.c: 5: Warning: Integer Overflow
After running:
The max value of int on 32 machine: 2147483647
After VC6.0 and java are compiled, there is no error.
After running:
The max value of int on 32 machine: 2147483647
Because the highest bit of the int is the symbol bit.