How many double numbers are there between 0.0 and 1.0?
Posted
by polygenelubricants
on Stack Overflow
See other posts from Stack Overflow
or by polygenelubricants
Published on 2010-06-05T02:51:23Z
Indexed on
2010/06/05
7:22 UTC
Read the original article
Hit count: 185
This is something that's been on my mind for years, but I never took the time to ask before.
Many (pseudo) random number generators generate a random number between 0.0 and 1.0. Mathematically there are infinite numbers in this range, but double
is a floating point number, and therefore has a finite precision.
So the questions are:
- Just how many
double
numbers are there between 0.0 and 1.0? - Are there just as many numbers between 1 and 2? Between 100 and 101? Between 10^100 and 10^100+1?
Note: if it makes a difference, I'm interested in Java's definition of double
in particular.
© Stack Overflow or respective owner