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                         maximum
signed    8 bit                        -128                            +127
signed   16 bit                     -32 768                         +32 767
signed   32 bit              -2 147 483 648                  +2 147 483 647
signed   64 bit  -9 223 372 036 854 775 808      +9 223 372 036 854 775 807
unsigned  8 bit                           0                            +255
unsigned 16 bit                           0                         +65 535
unsigned 32 bit                           0                  +4 294 967 295
unsigned 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                         maximum

SIGNED
byte:     8 bit                        -128                            +127
short:   16 bit                     -32 768                         +32 767
int:     32 bit              -2 147 483 648                  +2 147 483 647
long:    64 bit  -9 223 372 036 854 775 808      +9 223 372 036 854 775 807

UNSIGNED
char     16 bit                           0                         +65 535
Answer from gaborsch on Stack Overflow
Top answer
1 of 11
450

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                         maximum
signed    8 bit                        -128                            +127
signed   16 bit                     -32 768                         +32 767
signed   32 bit              -2 147 483 648                  +2 147 483 647
signed   64 bit  -9 223 372 036 854 775 808      +9 223 372 036 854 775 807
unsigned  8 bit                           0                            +255
unsigned 16 bit                           0                         +65 535
unsigned 32 bit                           0                  +4 294 967 295
unsigned 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                         maximum

SIGNED
byte:     8 bit                        -128                            +127
short:   16 bit                     -32 768                         +32 767
int:     32 bit              -2 147 483 648                  +2 147 483 647
long:    64 bit  -9 223 372 036 854 775 808      +9 223 372 036 854 775 807

UNSIGNED
char     16 bit                           0                         +65 535
2 of 11
84

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.

🌐
Runestone Academy
runestone.academy › ns › books › published › apcsareview › VariableBasics › minAndMax.html
3.7. Integer Min and Max — AP CSA Java Review - Obsolete
What do the last two lines print out? Did this surprise you? Java will actually return the maximum integer value if you try to subtract one from the minimum value. This is called underflow. And, Java will return the minimum integer value if you try to add one to the maximum.
🌐
GeeksforGeeks
geeksforgeeks.org › java › integer-max_value-and-integer-min_value-in-java-with-examples
Integer.MAX_VALUE and Integer.MIN_VALUE in Java with Examples - GeeksforGeeks
July 12, 2025 - // Java program to show what happens when // a value less than Integer.MIN_VALUE // is stored in an int variable class GFG { // Driver code public static void main(String[] arg) { try { System.out.println( "Trying to initialize" + " a N with value" + " Integer.MIN_VALUE - 1"); // Try to store value Integer.MIN_VALUE - 1 int N = Integer.MIN_VALUE - 1; // Print the value of N System.out.println("N = " + N); } catch (Exception e) { System.out.println(e); } } }
🌐
TutorialsPoint
tutorialspoint.com › integer-max-value-and-integer-min-value-in-java-with-examples
Integer.MAX_VALUE and Integer.MIN_VALUE in Java with Examples
The Integer class of Java provides two constants named Integer.MAX_VALUE and Integer.MIN_VALUE represents the maximum and minimum possible values for an integer variable in Java. The actual value of Integer.MAX_VALUE is 231 -1 which is equivalent to 2147483647 and the actual value of ...
🌐
Baeldung
baeldung.com › home › core concepts › programming › maximum value of an integer: java vs c vs python
Maximum Value of an Integer: Java vs C vs Python | Baeldung on Computer Science
March 18, 2024 - In this section, we’ll answer our questions starting from the old friend C to the relatively new Python, passing through the evergreen Java. Let’s start. The C language was designed in 1972, with the purpose of working the same way on different machine types. So, it doesn’t determine directly a range for the integer data type as that depends on machine architecture.
🌐
Reddit
reddit.com › r/learnjava › why does 2 * integer.max_value return -2?
r/learnjava on Reddit: Why does 2 * Integer.MAX_VALUE return -2?
May 21, 2022 -

I know that an int is a 32 bit number with a range of -2,147,483,648 to 2,147,483,647. I'm learning about overflow, and I am trying to figure out why 2 * Integer.MAX_VALUE returns -2.

Would anyone mind explaining overflow and why this is calculated this way, please?

Thank you in advance! :)

Edit: Thanks for the replies, everyone. I still don't completely understand it, but at least I have a good start to go down the rabbit hole of binary and hexadecimal numbers! :D

Edit #2: I think I get it now, and if anyone is curious this stack overflow question explains it well. Thanks again for the responses.

🌐
Reddit
reddit.com › r/learnjava › beginner here; please help with explaining why integer.max_value and integer.min_value is assigned as values in this code.
r/learnjava on Reddit: Beginner here; please help with explaining why Integer.MAX_VALUE and Integer.MIN_VALUE is assigned as values in this code.
July 4, 2022 -

I was searching for a way to find the min and max value within a number of integers and I came across this code:

Scanner in = new Scanner(System.in);

int maxNum = Integer.MIN_VALUE;
int minNum = Integer.MAX_VALUE;
while (scanner.hasNextInt()) {
  int num = scanner.nextInt();
  maxNum = Math.max(maxNum, num);
  minNum = Math.min(minNum, num);
}

System.out.println("The maximum number: " + maxNum);
System.out.println("The minimum number: " + minNum);

I am struggling to wrap my mind around Integer.MAX_VALUE and Integer.MIN_VALUE. Why are they assigned as values and how does it work with the Math. min & max methods. Why is the variable maxNum assigned the value Integer.MIN_VALUE and minNum assigned the value Integer.MAX_VALUE?

Thanks.

Top answer
1 of 3
3
Think of only one, you are looking for the lowest number in an array, you take the first number and compare it to your minValue, if it is smaller you choose that as new minValue and try the next. If you start minValue as the absolute MIN_VALUE, it will never find a smaller number in your array. SO you should start minValue as higher as possible and maxValue as lover. (Or you can just initiate them as the first number in your array)
2 of 3
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full - best also formatted as code block You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
Find elsewhere
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Integer.html
Integer (Java Platform SE 8 )
October 20, 2025 - Adds two integers together as per the + operator. ... Returns the greater of two int values as if by calling Math.max. ... Returns the smaller of two int values as if by calling Math.min. ... Java™ Platform Standard Ed.
🌐
Educative
educative.io › answers › what-is-integermaxvalue
What is Integer.MAX_VALUE?
Integer.MAX_VALUE represents the maximum positive integer value that can be represented in 32 bits (i.e., 2147483647). This means that no number of type Integer that is greater than 2147483647 can exist in Java.
🌐
Oracle
docs.oracle.com › javase › tutorial › java › nutsandbolts › datatypes.html
Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)
int: By default, the int data type is a 32-bit signed two's complement integer, which has a minimum value of -231 and a maximum value of 231-1. In Java SE 8 and later, you can use the int data type to represent an unsigned 32-bit integer, which has a minimum value of 0 and a maximum value of 232-1.
🌐
CodeGym
codegym.cc › java blog › java numbers › integer max_value in java with examples
Integer MAX_VALUE in Java with Examples
December 10, 2024 - Thus, there are 2^31-1 possible values. Hence, there is no integer greater than the number 2^31-1 in Java. It is used to automatically assign any variable the maximum integer possible without requiring to remember the exact number.
🌐
iO Flood
ioflood.com › blog › integer-max-value-java
Java's Integer.MAX_VALUE Explained: A Complete Guide
March 11, 2024 - Let’s see an example of an integer overflow in action: int maxValue = Integer.MAX_VALUE; System.out.println("Max value: " + maxValue); maxValue++; System.out.println("Max value after increment: " + maxValue); // Output: // Max value: 2147483647 // ...
🌐
javaspring
javaspring.net › blog › java-integer-max-value-vs-kotlin-int-max-value
Java Integer.MAX_VALUE vs Kotlin Int.MAX_VALUE: Why 0xFFFFFFFF Throws an Exception in Kotlin But Works in Java? — javaspring.net
In Java, integer literals are typed based on their value: A hexadecimal literal is an int if its value fits in [-2147483648, 2147483647]. If it exceeds this range, it’s treated as a long (64-bit signed integer).
🌐
Dot Net Perls
dotnetperls.com › integer-java
Java - Integer Max, Min and Size - Dot Net Perls
In Java the numeric classes, like Byte and Integer, have public final fields (constants). These tell us properties of the number types themselves. To start, MAX_VALUE and MIN are helpful in loops. Sometimes you may want a high number—the maximum constant is convenient. And To loop through the entire range of positive ints...
🌐
C# Corner
c-sharpcorner.com › article › integer-maxvalue-and-integer-minvalue-in-java
Integer.MAX_VALUE and Integer.MIN_VALUE in Java
October 9, 2025 - Integer.MIN_VALUE represents the smallest (most negative) value. Because Java’s int is a 32-bit signed integer (using two’s complement representation), its range is: From -2³¹ to 2³¹ − 1, i.e., −2,147,483,648 to +2,147,483,647.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › int-vs-Integer-java-difference-comparison-primitive-object-types
Integer vs. int: What's the difference?
The Java Integer class has methods and properties, something the primitive type int does not. Some of the helpful methods of the Java Integer class include: MIN_VALUE and MAX_VALUE to help determine the range.