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.

🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Integer.html
Integer (Java Platform SE 8 )
2 days ago - 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.
Discussions

Why does 2 * Integer.MAX_VALUE return -2?
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. More on reddit.com
🌐 r/learnjava
20
14
May 21, 2022
Why Integer.MAX_VALUE + Integer.MAX_VALUE result in -2?
Hmm, I just realize that r/java sidebar has http://www.reddit.com/r/javahelp which I suppose to use for this kind of question... Sorry guys. ... If a 32 bit Int's max value is 2,147,483,647, why is it only 31 bits in length when converted to binary? More on reddit.com
🌐 r/java
8
0
May 16, 2013
Eli5 why is 2^32 the maximum number for an int?
Ignoring negative numbers: If you write a 3-digit number, that goes from 000 to 999. A 4-digit number goes from 0000 to 9999. With n digits, the upper limit is always 10n - 1. Well, a 32-bit integer is exactly a 32-digit number, except it's binary instead of decimal, so each digit can only be 0 or 1 (two values) instead of 0-9 (ten values) . So, instead of 1032 - 1, you get an upper limit of 232 - 1. What happens when you run out? Integer overflow . There's three common ways to deal with overflow: Wrapping. Like when the odometer on your car rolls over from 999km to 000km, or your watch goes from 11:59 to 00:00. Saturation. No matter how much you press the "volume up" button, your sound won't go above 100%. Error. This shouldn't happen, and I don't know how to deal with it, so I'll just scream loudly and let somebody else handle it Most programming languages default to the wrapping strategy, because it kind of makes sense (kind of). More on reddit.com
🌐 r/explainlikeimfive
45
0
January 11, 2024
Lisette a little language inspired by Rust that compiles to Go
I do think there may be a limit to how far it can be improved, though. Like typed nil means that a variable of an interface type (say coming from pure Go code) should enter Lisette as Option>. Sure, one can match on Some(Some(h)) to not require two unwrapping steps, but ... More on news.ycombinator.com
🌐 news.ycombinator.com
154
271
April 23, 2026
🌐
Runestone Academy
runestone.academy › ns › books › published › apcsareview › VariableBasics › minAndMax.html
3.7. Integer Min and Max — AP CSA Java Review - Obsolete
Why is there one more negative number than positive number? It is because 0 is considered a positive number. 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.
🌐
CodeGym
codegym.cc › java blog › java numbers › integer max_value in java with examples
Integer MAX_VALUE in Java with Examples
December 10, 2024 - The Integer MAX_VALUE in Java is a constant that represents the maximum positive integer value. Integer.MAX_VALUE is a number in the Java Integer сlass of java.lang package. It is the maximum possible Integer number that can be represented in 32 bits...
🌐
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 - Most of the times, in competitive programming, there is a need to assign the variable, the maximum or minimum value that data type can hold, but remembering such a large and precise number comes out to be a difficult job. Therefore, Java has constants to represent these numbers, so that these can be directly assigned to the variable without actually typing the whole number. Integer.MAX_VALUE Integer.MAX_VALUE is a constant in the Integer class of java.lang package that specifies that stores the maximum possible value for any integer variable in Java.
🌐
Code Like A Girl
code.likeagirl.io › what-happens-when-you-add-1-to-integer-max-value-in-java-09020d0906a7
What Happens When You Add 1 to Integer.MAX_VALUE in Java | by Nouhaila El Ouadi | Code Like A Girl
October 23, 2024 - When you add 1 to Integer.MAX_VALUE (2,147,483,647), there's no more room to store the result within the 32 bits available for an int. Join Medium for free to get updates from this writer. ... This binary number represents -2,147,483,648 in two’s ...
Find elsewhere
🌐
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.

🌐
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 - This means, as with Java BigInteger, we use as much memory as needed for an arbitrarily big integer. So, in terms of programming language, this question doesn’t apply at all for Python, cause the plain integer type is, theoretically unbounded. What is not unbounded is the current interpreter’s word size, which is the same as the machine’s word size in most cases. That information is available in Python as sys.maxsize...
🌐
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 - In this article, we’ll explain what these constants mean, how they are defined, when to use them, and show practical Java examples. We'll also explore related constants, such as Long.MAX_VALUE and Long.MIN_VALUE for larger numbers. Integer.MAX_VALUE represents the largest value an int can hold in Java.
🌐
W3Schools
w3schools.com › java › ref_math_max.asp
Java Math max() Method
assert abstract boolean break byte case catch char class continue default do double else enum exports extends final finally float for if implements import instanceof int interface long module native new package private protected public return requires short static super switch synchronized this throw throws transient try var void volatile while Java String Methods
🌐
Reddit
reddit.com › r/explainlikeimfive › eli5 why is 2^32 the maximum number for an int?
r/explainlikeimfive on Reddit: Eli5 why is 2^32 the maximum number for an int?
January 11, 2024 -

I understand that half are positive and half are negative. But why specifically is that the upper limiter? To further that, what would happen if a system hit the number 2,147,483,648?

Top answer
1 of 5
55
Ignoring negative numbers: If you write a 3-digit number, that goes from 000 to 999. A 4-digit number goes from 0000 to 9999. With n digits, the upper limit is always 10n - 1. Well, a 32-bit integer is exactly a 32-digit number, except it's binary instead of decimal, so each digit can only be 0 or 1 (two values) instead of 0-9 (ten values) . So, instead of 1032 - 1, you get an upper limit of 232 - 1. What happens when you run out? Integer overflow . There's three common ways to deal with overflow: Wrapping. Like when the odometer on your car rolls over from 999km to 000km, or your watch goes from 11:59 to 00:00. Saturation. No matter how much you press the "volume up" button, your sound won't go above 100%. Error. This shouldn't happen, and I don't know how to deal with it, so I'll just scream loudly and let somebody else handle it Most programming languages default to the wrapping strategy, because it kind of makes sense (kind of).
2 of 5
9
232 is 32 bits. That's how many binary digits a 32 bit CPU can handle at a time. 64 bit CPUs can of course handle up to 64 binary digits, and 32 bit CPUs can handle 64 bit or more digits but it has to do any maths in several steps instead of in one step. Just a quick refresher on binary counting: 00000000000000000000000000000000 = 0 00000000000000000000000000000001 = 1 00000000000000000000000000000010 = 2 00000000000000000000000000000011 = 3 00000000000000000000000000000100 = 4 00000000000000000000000000000101 = 5 ... 11111111111111111111111111111111 = 4294967295 00000000000000000000000000000000 = 0 So unsigned 32 bit numbers can be from 0 to 4294967295 (232 - 1). If you reach the end and +1, it loops back to 0. Ok where are the negative numbers? binary numbers can also be signed, where the numbers loop round from max positive to max negative (the first bit isn't exactly a negative sign, but any numbers with the first bit 1 is negative). Some counting with signed numbers: 01111111111111111111111111111100 = 2147483644 01111111111111111111111111111101 = 2147483645 01111111111111111111111111111110 = 2147483646 01111111111111111111111111111111 = 2147483647 10000000000000000000000000000000 = -2147483648 10000000000000000000000000000001 = -2147483647 10000000000000000000000000000010 = -2147483646 ... 11111111111111111111111111111101 = -3 11111111111111111111111111111110 = -2 11111111111111111111111111111111 = -1 00000000000000000000000000000000 = 0 00000000000000000000000000000001 = 1 Why does it do this looping round thing instead of just making the first digit be a positive/negative sign? It means you can actually ignore the sign when adding numbers and the positives / negative still work regardless.
🌐
Tutorialspoint
tutorialspoint.com › java › lang › math_max_int.htm
Java - Math max(int x, int y) Method
The java.lang.Math.max(int a, int b) returns the greater of two int values. That is, the result is the argument closer to positive infinity. If the arguments have the same value, the result is that same value.
🌐
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.
🌐
Hacker News
news.ycombinator.com › item
Lisette a little language inspired by Rust that compiles to Go | Hacker News
April 23, 2026 - I do think there may be a limit to how far it can be improved, though. Like typed nil means that a variable of an interface type (say coming from pure Go code) should enter Lisette as Option<Option<http.Handler>>. Sure, one can match on Some(Some(h)) to not require two unwrapping steps, but ...
🌐
Wikipedia
en.wikipedia.org › wiki › Year_2038_problem
Year 2038 problem - Wikipedia
2 days ago - This limits the year to a maximum of 2,147,485,547 (2,147,483,647 + 1900). Alternative proposals have been made (some of which are already in use), such as storing either milliseconds or microseconds since an epoch (typically either 1 January 1970 or 1 January 2000) in a signed 64-bit integer, providing a minimum range of 292,000 years at microsecond resolution. In particular, Java...
🌐
GeeksforGeeks
geeksforgeeks.org › java › min-and-max-in-a-list-in-java
Min and Max in a List in Java - GeeksforGeeks
January 22, 2026 - After sorting, the first element becomes the minimum and the last element becomes the maximum. ... import java.util.*; public class GFG { public static Integer findMin(List<Integer> list) { if (list == null || list.isEmpty()) return Integer.MAX_VALUE; List<Integer> sortedList = new ArrayList<>(list); Collections.sort(sortedList); return sortedList.get(0); } public static Integer findMax(List<Integer> list) { if (list == null || list.isEmpty()) return Integer.MIN_VALUE; List<Integer> sortedList = new ArrayList<>(list); Collections.sort(sortedList); return sortedList.get(sortedList.size() - 1); } public static void main(String[] args) { List<Integer> list = new ArrayList<>(); list.add(44); list.add(11); list.add(22); list.add(33); System.out.println("Min: " + findMin(list)); System.out.println("Max: " + findMax(list)); } }
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › MAX_VALUE
Number.MAX_VALUE - JavaScript | MDN
October 22, 2025 - Values larger than MAX_VALUE are represented as Infinity and will lose their actual value. As mentioned in Number.EPSILON, the precision of numbers depends on their magnitude. Integers can only be represented precisely up to Number.MAX_SAFE_INTEGER, which is 253 - 1.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › ArrayList.html
ArrayList (Java Platform SE 8 )
2 days ago - a - the array into which the elements of the list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.