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

🌐
Programming.Guide
programming.guide › java › float-range.html
Java: Range of a float | Programming.Guide
In Java a float is a 32-bit IEEE 754 floating point. Float values are symmetrical around origo and has a maximum magnitude of 3.40282347e38
Discussions

floating point - Range of Float in Java - Stack Overflow
In these cases, you get some rounding issues, especially as float has a rather limited range for the mantissa. Executing your code with double (instead of float) gives you 3.5912062E7 as result. If your really wanna know what java (or the floating point arithmetic) makes of your number, you ... More on stackoverflow.com
🌐 stackoverflow.com
Floating and Double types range in java - Stack Overflow
I am beginner in Java and I am just reading one of the pdfs for beginners like me. So in my book I found this: So for example the floating point numbers may be within the range of 1.4E-45 to 3. More on stackoverflow.com
🌐 stackoverflow.com
When should I use double and when should I use float for Java?
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge. If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options: Limiting your involvement with Reddit, or Temporarily refraining from using Reddit Cancelling your subscription of Reddit Premium as a way to voice your protest. 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/learnprogramming
65
59
January 6, 2024
confused about the max limit we can store for float and double
Interestingly, a double can exactly represent any integer up to about 2^53. Here's more info on the max limits: https://en.wikipedia.org/wiki/IEEE_754 More on reddit.com
🌐 r/C_Programming
8
3
February 1, 2024
🌐
Baeldung
baeldung.com › home › java › java numbers › float vs. double in java
Float vs. Double in Java | Baeldung
January 4, 2025 - The delta of 1e-15 accounts for minor rounding differences in double precision. The range of a floating-point data type defines the smallest and largest values it can represent, and the ranges of float and double differ significantly.
🌐
Software Testing Help
softwaretestinghelp.com › home › java › java float tutorial with programming examples
Java Float Tutorial With Programming Examples
April 1, 2025 - Floating-point numbers are those numbers that require “fractional precision” i.e. the numbers that can be in the fraction. There are a lot of mathematical calculations where we can use Floating-Point types like finding square root or cube root of any number, finding roots of quadratic equation, dealing with trigonometries like sin and cos, and so on. ... Enlisted below are the details about float and double type. The range is approximate. As you can clearly see, the float is smaller and has a lesser range than Java double.
Find elsewhere
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Float.html
Float (Java Platform SE 8 )
July 21, 2026 - If the argument is any value in the range 0x7f800001 through 0x7fffffff or in the range 0xff800001 through 0xffffffff, the result is a NaN. No IEEE 754 floating-point operation provided by Java can distinguish between two NaN values of the same type with different bit patterns.
🌐
DataCamp
datacamp.com › doc › java › float
float Keyword in Java: Usage & Examples
Float floatObject = Float.valueOf(a); // Using Float classPowered by · Range of Values: The float data type can store numbers from approximately 3.4e−038 to 3.4e+038, which is useful when dealing with very large or very small values. Build your Java skills from the ground up and master ...
🌐
Scaler
scaler.com › home › topics › float vs double in java - difference you should know
Float Vs Double in Java - Difference You Should Know - Scaler Topics
March 27, 2024 - Also when the memory is a constraint, we must use float data type, as it consumes half of the memory double consumes. So, if we want to consume memory efficiently and if the data is in a smaller range or 16 precision decimal digits are not required, the float will be the best and optimal data ...
🌐
W3Schools
w3schools.com › java › ref_keyword_float.asp
Java float Keyword
The float keyword is a data type that can store fractional numbers from 3.4e−038 to 3.4e+038.
🌐
Oracle
docs.oracle.com › javase › tutorial › java › nutsandbolts › datatypes.html
Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)
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. As with the recommendations for byte and short, use a float (instead of double) if you need to save memory in large arrays of floating point numbers.
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › lang › Float.html
Float (Java SE 21 & JDK 21)
January 20, 2026 - If the argument is any value in the range 0x7f800001 through 0x7fffffff or in the range 0xff800001 through 0xffffffff, the result is a NaN. No IEEE 754 floating-point operation provided by Java can distinguish between two NaN values of the same type with different bit patterns.
🌐
Javatpoint
javatpoint.com › float-vs-double-java
Float Vs Double Java - Javatpoint
Float Vs Double Java with java tutorial, features, history, variables, object, programs, operators, oops concept, array, string, map, math, methods, examples etc.
🌐
ZetCode
zetcode.com › java › float-types
Java Floating-Point Numbers - Complete Guide
Java's float type is a 32-bit IEEE 754 single-precision number, holding 6-7 significant digits with a range of ±1.4×10⁻⁴⁵ to ±3.4×10³⁸, marked by an ‘f' suffix. The double type, a 64-bit double-precision variant, offers 15-16 digits and spans ±4.9×10⁻³²⁴ to ±1.7×10³⁰⁸, ...
🌐
iO Flood
ioflood.com › blog › java-float
Java Float Keyword Explained: Usage and Examples
February 26, 2024 - But before we dive deeper, let’s understand some key properties of float. ... Is a single-precision 32-bit IEEE 754 floating point. Has a size of 4 bytes. Can hold values ranging from 1.4e-45 to 3.4e+38.
🌐
Coderanch
coderanch.com › t › 407588 › java › Data-range-float-double-types
Data range of float and double types (Beginning Java forum at Coderanch)
July 13, 2007 - My question is we know that float occupies 32 bits and double occupies 64 bit. Why cant we mention that float data range is -2 power 31 ro 2 power 31 -1 and same with double? ... For an N-bit signed integer stored in two's complement, the range is -(2^(N-1)) to 2^(N-1) - 1.
🌐
Tutorialspoint
tutorialspoint.com › java › lang › number_floatvalue.htm
Java - Number floatValue() Method
The Java Number floatValue() method ... IEEE 754 floating point value. The range of a float value starts from 3.40282347 x 1038 to 1.40239846 x 10-45....