-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
  • 195,986
  • 40
  • 382
  • 396
DRastislav
  • 1,872
  • 3
  • 25
  • 38

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
  • 168,892
  • 12
  • 149
  • 276
Woot4Moo
  • 23,491
  • 13
  • 90
  • 146
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,429
  • 9
  • 50
  • 91
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,357
  • 20
  • 39