Besides the fact that the real numbers ℝ go on forever whereas the floats only go up to a certain point (Float.MAX_VALUE) in Java, what else could I compare between these two sets of numbers?
2 Answers
The set of double precision floating point numbers in Java has the following elements:
Integers from 1 to $2^{53}-1$, multiplied by $2^e$ for integers e in some fixed range (which I am too lazy to look up right now).
+Infinity and -Infinity
+NaN and -NaN
+0 and -0.
The last six are not real numbers (+0 and -0 are both similar, but not quite the same as the real number 0).
Real numbers which are not Java floating-point numbers are 0, those numbers that are either too large or too small, requiring an integer e outside the allowable range, those that are not integer multiples of a power of two, and those that are integer multiples of a power of two with an integer > $2^{53}$.
The most important difference is that there are infinitely many real numbers and only finitely many floats.
Indeed, between any two numbers $a<b$, the set $\mathbb R \cap (a,b)$ is uncountably infinite (countably if you intersect with $\mathbb Q$ instead).
That is not the case with the floats.
Furthermore, the floating point numbers are well-ordered, i.e. any set $S$ of floating point numbers has a smallest element, whereas that's not the case with the reals.
nan
s. $\endgroup$