IEEE-754: cardinality of the set of rational numbers

柔情痞子 提交于 2019-12-02 04:13:43

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;
  unsigned int i;
  memcpy(&i, &f, 4);
  printf("%u\n", i);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!