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

🌐
DataCamp
datacamp.com β€Ί doc β€Ί java β€Ί double
double Keyword in Java: Usage & Examples
The double keyword in Java is a primitive data type that represents a double-precision 64-bit IEEE 754 floating point. It is used to store decimal numbers with a higher degree of precision compared to the float data type. The double data type is commonly used in situations that require a large ...
🌐
Oracle
docs.oracle.com β€Ί javase β€Ί 7 β€Ί docs β€Ί api β€Ί java β€Ί util β€Ί Arrays.html
Arrays (Java Platform SE 7 )
Assigns the specified double value to each element of the specified range of the specified array of doubles. The range to be filled extends from index fromIndex, inclusive, to index toIndex, exclusive.
🌐
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
🌐
Quora
quora.com β€Ί In-Java-how-do-you-double-the-length-of-an-array
In Java how do you double the length of an array? - Quora
You can create a new array with twice the size of the existing one and copy over the elements of the existing array, preferably via System.arraycopy(). But tell me, how does a linked list have anything to do with ...
🌐
TutorialsPoint
tutorialspoint.com β€Ί java β€Ί util β€Ί arrays_copyofrange_double.htm
Java Arrays copyOfRange() Method
Java Arrays copyOfRange() Method - The Java Arrays copyOfRange(double[] original, int from, int to) method copies the specified range of the specified array into a new array.The final index of the range (to), which must be greater than or equal ...
Find elsewhere
🌐
Coderanch
coderanch.com β€Ί t β€Ί 368695 β€Ί java β€Ί Range-Data-Type-double
Range of Data Type double (Java in General forum at Coderanch)
programming forums Java Mobile ... possible by our volunteer staff, including ... ... As per the Book, long Data Types Range is -9223372036854775808 to 9223372036854775807....
🌐
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.
🌐
Trinket
books.trinket.io β€Ί thinkjava β€Ί chapter8.html
Arrays | Think Java | Trinket
The first assignment makes count refer to an array of four integers. The second makes values refer to an array of double, where the number of elements in values depends on the value of size. Of course, you can also declare the variable and create the array in a single line of code:
🌐
Software Testing Help
softwaretestinghelp.com β€Ί home β€Ί java β€Ί java double – tutorial with programming examples
Java Double - Tutorial With Programming Examples
April 1, 2025 - As we all know, Java has eight primitive types i.e. int, short, long, byte, float, double, char, and boolean. The Java double is one of the primitive data types whose width and range is more than float.
🌐
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.
🌐
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 ...
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.ddd…ddd2, 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

🌐
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)
Constructs a new DoubleRange using the specified number as both the minimum and maximum 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).
🌐
Coderanch
coderanch.com β€Ί t β€Ί 658900 β€Ί java β€Ί Array-range-numbers
Array range of numbers (Beginning Java forum at Coderanch)
It would seem, however, that you haven't read thoroughly enough, because what you wrote will NOT return a range that includes both 0 and 1000. I suggest you look over it again. Carefully. My reason for writing it was so that you could learn from it; not parrot it. Winston Β· "Leadership is nature's way of removing morons from the productive flow" - Dogbert Articles by Winston can be found here ... Ok, I know I'm coming late into the piece, but you do know to use square brackets with arrays right?
🌐
Greenteapress
greenteapress.com β€Ί thinkapjava β€Ί html β€Ί thinkjava014.html
Arrays
An array is a set of values where each value is identified by an index. You can make an array of ints, doubles, or any other type, but all the values in an array have to have the same type Β· Syntactically, array types look like other Java types except they are followed by []. For example, ...