【发布时间】:2015-04-16 05:44:07
【问题描述】:
我试图弄清楚如何打印出浮点数是 QNAN 还是 SNAN。我已经将这些位分成了 signBit exponentBit 和 FractBits。
unsigned int sign = (i & 0x80000000) >> 31;
unsigned int exponent = (i & 0x7f800000) >> 23;
unsigned int fraction = (i & 0x007FFFFF);
printf("signBit %d, expBits %d, fractBits 0x%08X\n",sign, exponent, fraction);
【问题讨论】:
-
您可以从common mathematical functions in the standard library 获得一些 帮助,您还可以使用
std::numeric_limits确定一个类型是否具有不同的NaN 类型。 -
IEEE 754 没有定义特定 NaN 的二进制格式。信令 NaN 的存在和格式取决于平台(通常是硬件和操作系统)。
标签: c++ c gcc assembly ieee-754