IEEE-754: cardinality of the set of rational numbers
What is the cardinality of the set of rational numbers, which have an exact representation in floating point format compatible with single-precision IEEE-754? There are 2139095039 finite positive floats. There are as many finite negative floats. Do you want to include +0.0 and -0.0 as two items or as one? Depending on the answer the total is 2 * 2139095039 + 2 or 2 * 2139095039 + 1, that is, respectively, 4278190080 or 4278190079. Source for the 2139095039 number: #include <float.h> #include <math.h> #include <stdlib.h> #include <stdio.h> #include <string.h> int main(void) { float f = FLT_MAX;