Java's Primitive Data Types

boolean: 1-bit. May take on the values true and false only.

byte: 1 signed byte (two's complement). Covers values from -128 to 127.

short: 2 bytes, signed (two's complement), -32,768 to 32,767

int: 4 bytes, signed (two's complement). -2,147,483,648 to 2,147,483,647.

long: 8 bytes signed (two's complement). Ranges from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807.

float: 4 bytes, IEEE 754. Covers a range from 1.40129846432481707e-45 to 3.40282346638528860e+38 (positive or negative).

double: 8 bytes IEEE 754. Covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative).

char: 2 bytes, unsigned, Unicode, 0 to 65,535

🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › Float-vs-Double-Whats-the-difference
Java double vs float: What's the difference?
From the output of the program above, we see the size difference between float and double Java types is: The upper range of a double in Java is 1.7976931348623157E308.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › Java-double-precision-2-decimal-places-example-float-range-math-jvm
Java double decimal precision
To simplify display, you can use %d printf notation to format a Java double’s precision to two decimal places, while internally the double variable’s precision is maintained. The Double wrapper class provides two properties that represent the range of a Java double:
🌐
Programming.Guide
programming.guide › java › double-range.html
Java: Range of a double | Programming.Guide
In Java, a double is a 64-bit IEEE 754 floating point. Double values are symmetrical around origo and has a maximum magnitude of 1.7976931348623157e308
🌐
DataCamp
datacamp.com › doc › java › double
double Keyword in Java: Usage & Examples
The range for double values is approximately from 4.9e-324 to 1.7e+308. ... public class DoubleExample { public static void main(String[] args) { double pi = 3.14159; double gravity = 9.81; System.out.println("Value of pi: " + pi); System.out.println("Value of gravity: " + gravity); } } In ...
🌐
Apache Commons
commons.apache.org › proper › commons-lang › javadocs › api-2.4 › org › apache › commons › lang › math › DoubleRange.html
DoubleRange (Commons Lang 2.4 API)
$Id: DoubleRange.java 437554 2006-08-28 06:21:41Z bayard $ Author: Stephen Colebourne · See Also: Serialized Form · public DoubleRange(double number) Constructs a new DoubleRange using the specified number as both the minimum and maximum in this range. Parameters: number - the number to use ...
Top answer
1 of 2
1

Java uses the IEEE-754 binary64 format. In this format, one bit represents a sign (+ or − according to whether the bit is 0 or 1), eight bits are used for an exponent, and 52 bits are used for the primary encoding of the significant. One bit of the 53-bit significand is encoded via the exponent.

The values of the exponent field range from 0 to 2047. 2047 is reserved for use with infinities and NaNs. 0 is used for subnormal numbers. The values 1 to 2046 are used for normal numbers. In this range, an exponent field value of E represents an exponent e = E−1023. So the lowest value of e is 1−1023 = −1022, and the highest value is 2046−1023 = 1023. An exponent field value of 0 also represents the lowest value of E, −1022.

The 53-bit significand represents a binary numeral d.dddddd2, where the first d is 0 if the exponent field is 0 and 1 if the exponent field is 1 to 2046. There are 52 bits after the “.”, and they are given by the primary significand field.

Let S be the sign bit field, E be the value of the exponent field, and F be the value of the primary significand field as an integer. Then the value represented is:

  • if E is 1 to 2046, (−1)S • 2E−1023 • (1 + F•2−52),
  • if E is 0, (−1)S • 2−1022 • (0 + F•2−52).

Now we can see the smallest positive number is represented when S is 1, E is 0, and F is 1 (00000000000000000000000000000000000000000000000000012). Then the value represented is (−1)0 • 2−1022 • (0 + 1•2−52) = +1 • 2−1022 • 2−52 = 2−1074.

The greatest finite number is represented when S is 1, E is 2046, and F is 252−1 (11111111111111111111111111111111111111111111111111112). Then the value represented is (−1)0 • 22046−1023 • (1 + (252−1)•2−52 = +1 • 21023 • (1 + 1 − 2−52) = 21023 • (21 − 2−52) = 21024 − 2971.

2 of 2
0

It's the same thing for floating-point values as for integer values - the number of bits available.

An IEEE double-length floating point value has 64 bits, used as follows:

Sign bit: 1 bit
Exponent: 11 bits
Significand precision: 52 bits

The significand is a binary fraction, the maximum value (all bits set) is therefore somewhat less than one.

The exponent has value 0 to 2047, or -1024 to +1023. That gives you the approximate range of 2 to the -1024 to 2 to the +1023 (it's actually less since a couple of values are reserved for specific use).

Wikiipedia for more exact details

Find elsewhere
🌐
Quora
quora.com › What-is-the-range-of-the-double-data-type-in-Java
What is the range of the double data type in Java? - Quora
Answer (1 of 4): The range of double in Java is 1.7976931348623157 x 10^308 to 4.9406564584124654 x 10^-324. The java documentation mentions all such details of different data types and all the classes, interfaces and function that are shipped ...
🌐
Software Testing Help
softwaretestinghelp.com › home › java › java double – tutorial with programming examples
Java Double - Tutorial With Programming Examples
April 1, 2025 - Java double is used to represent floating-point numbers. It uses 64 bits to store a variable value and has a range greater than float type. ... In this example, we are calculating the square root of the area of a rectangle.
🌐
Coderanch
coderanch.com › t › 368695 › java › Range-Data-Type-double
Range of Data Type double (Java in General forum at Coderanch)
As per the Book, long Data Types Range is -9223372036854775808 to 9223372036854775807. I got an error message while compiling this above statement.The Error message is : "integer number too large: 922337203685477580".
🌐
CodeGym
codegym.cc › java blog › java numbers › java double keyword
Java double keyword
February 19, 2025 - Float is 32 bits, of which 1 bit is signed bit, 8 bit for exponent and 23 bit for significand. It's range is ±3.40282347E + 38F i.e. 6-7 significant digits. The name double comes ...
🌐
Apache Commons
commons.apache.org › proper › commons-lang › javadocs › api-2.6 › org › apache › commons › lang › math › DoubleRange.html
DoubleRange (Commons Lang 2.6 API)
Constructs a new DoubleRange using ... in this range. ... Constructs a new DoubleRange with the specified minimum and maximum numbers (both inclusive). The arguments may be passed in the order (min,max) or (max,min). The getMinimum and getMaximum methods will return the correct values.
🌐
Baeldung
baeldung.com › home › java › java numbers › float vs. double in java
Float vs. Double in Java | Baeldung
January 4, 2025 - In contrast, a double extends this range significantly, from -1.7e-308 to +1.7e+308, making it the preferred choice for applications that demand greater numerical reach, such as scientific simulations or astronomical calculations.
🌐
Deep Java
java.digibeatrix.com › home › java fundamentals › java double explained: range, precision, common pitfalls, and bigdecimal alternatives
Java double Explained: Range, Precision, Common Pitfalls, and BigDecimal Alternatives - Deep Java
December 31, 2025 - In the example above, float y = 1.23; fails because 1.23 is interpreted as a double. If you want it to be treated as a float, you must explicitly specify it like this: ... This behavior shows that in Java, double is the default for decimal ...
🌐
Coderanch
coderanch.com › t › 557189 › java › Increase-range-Double
Increase the range of Double (Java in General forum at Coderanch)
In the JFormattedTextField it will allow 1,000.00 but the db crashes when this Decimal is presented. Will I have to change the db data type ? Going back to your original question, the answer is YES. If you need to pass a value that is more than 999.99, then you will have to change the database definition, regardless of what Java type you use.
🌐
Oracle
docs.oracle.com › javadb › 10.10.1.2 › ref › rrefsqljdoubleprecision.html
DOUBLE PRECISION data type
Derby throws an exception if an operation calculates or tries to store a value of NaN, positive infinity, or negative infinity, as defined by the IEEE 754 Standard for Binary Floating-Point Arithmetic and as represented with named constants in the Java programming language (for example, Double.NaN).
🌐
Oracle
docs.oracle.com › javase › tutorial › java › nutsandbolts › datatypes.html
Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)
Numbers and Strings covers BigDecimal and other useful classes provided by the Java platform. double: The double data type is a double-precision 64-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in the Floating-Point Types, Formats, and Values section of the Java Language Specification.