Learn with this article how to calculate range of Java integer types. You will never have to Google for the Jave type range table anymore!Calculating range of Java integer types is a very easy and simple process. Here is the process:

- Get storage amount of desired type, you can get it from the list below (it’s good (and simple) to memorize it)

**long – 8 bytes**

int – 4 bytes

short – 2 bytes

byte**– 1 byte** - Multiply amount of bytes 8 times, ie. for
**int**it is 4×8 = 32 - Use the value from Step 2 as exponent for power with base 2: 2³² = 4,294,967,296
- Divide the value from Step 3 by two to get negative range of your type: 4,294,967,296÷2 = 2,147,483,648
- Subtract 1 from the value from Step 4 to get the positive range of your type: 2,147,483,648 – 1 = 2,147,483,647
- You have calculated the type range! For
**int**from example, it is**-2,147,483,648 to 2,147,483,647**

Do you know any simpler method? Leave it in the comments!

## Learn more about Java

But why we are actually having the base value as 2

teja7 months agogood work

thanks a lot..

Martin PPP3 years agoInteresting.I am not exactly sure that it may be useful nowadays, where programmers do not have to care about single bytes of memory, but it is still interesting skill to posses.

kamaro4 years agouseful

piotrek4 years agooh i never know that it is so simple to calculate, very handy to know