-3

I am learning about the range of primitive types and I have question about type double.

If we know that double has 8 bytes (64 bits) - why is it impossible to determine minimum and maximum range of double?

long has 8 bytes as well but we can determine minimum and maximum.

Mat
  • 202,337
  • 40
  • 393
  • 406
DRastislav
  • 1,892
  • 3
  • 26
  • 40

3 Answers3

1

Pretty sure this is the maximum and minimum range:

MAX_VALUE A constant holding the largest positive finite value of type double, (2-2-52)·21023.

MIN_VALUE A constant holding the smallest positive nonzero value of type double, 2-1074.

according to the docs both of these functions return a primitive double.

Eric Postpischil
  • 195,579
  • 13
  • 168
  • 312
Woot4Moo
  • 23,987
  • 16
  • 94
  • 151
1

I wasn't aware that we wouldn't determine the minimum and maximum range of double. A quick google search shows:

Double covers a range from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative).

If you look at this question though, you can find out more information: What is the inclusive range of float and double in Java?

Community
  • 1
  • 1
Andrew Martin
  • 5,619
  • 10
  • 54
  • 92
0

Doubles are not stored the same way longs or ints are stored.

It is stored similar to scientific notation.

That is, a certain number of significant figures and a power.

Edit, the answer above indicates that there is a min and max. However, this is due to a limit on how high the power component of the double can be (i.e. it can only take up so many bits).

Chris Chambers
  • 1,367
  • 21
  • 39