max value of integer max value of integer c c

max value of integer


In C, the language itself does not determine the representation of certain datatypes. It can vary from machine to machine, on embedded systems the int can be 16 bit wide, though usually it is 32 bit.

The only requirement is that short int <= int <= long int by size. Also, there is a recommendation that int should represent the native capacity of the processor.

All types are signed. The unsigned modifier allows you to use the highest bit as part of the value (otherwise it is reserved for the sign bit).

Here's a short table of the possible values for the possible data types:

          width                     minimum                         maximumsigned    8 bit                        -128                            +127signed   16 bit                     -32 768                         +32 767signed   32 bit              -2 147 483 648                  +2 147 483 647signed   64 bit  -9 223 372 036 854 775 808      +9 223 372 036 854 775 807unsigned  8 bit                           0                            +255unsigned 16 bit                           0                         +65 535unsigned 32 bit                           0                  +4 294 967 295unsigned 64 bit                           0     +18 446 744 073 709 551 615

In Java, the Java Language Specification determines the representation of the data types.

The order is: byte 8 bits, short 16 bits, int 32 bits, long 64 bits. All of these types are signed, there are no unsigned versions. However, bit manipulations treat the numbers as they were unsigned (that is, handling all bits correctly).

The character data type char is 16 bits wide, unsigned, and holds characters using UTF-16 encoding (however, it is possible to assign a char an arbitrary unsigned 16 bit integer that represents an invalid character codepoint)

          width                     minimum                         maximumSIGNEDbyte:     8 bit                        -128                            +127short:   16 bit                     -32 768                         +32 767int:     32 bit              -2 147 483 648                  +2 147 483 647long:    64 bit  -9 223 372 036 854 775 808      +9 223 372 036 854 775 807UNSIGNEDchar     16 bit                           0                         +65 535


In C, the integer(for 32 bit machine) is 32 bit and it ranges from -32768 to +32767.

Wrong. 32-bit signed integer in 2's complement representation has the range -231 to 231-1 which is equal to -2,147,483,648 to 2,147,483,647.


A 32 bit integer ranges from -2,147,483,648 to 2,147,483,647. However the fact that you are on a 32-bit machine does not mean your C compiler uses 32-bit integers.