我知道有很多像这样的问题,但我找不到我的答案。一些浮点精度和数值限制问题
- 根据PC ASM:投票结束(前请仔细阅读。
The numeric coprocessor has eight floating point registers. Each register holds 80 bits of data. Floating point numbers are always stored as 80-bit extended precision numbers in these registers.
这怎么可能,当sizeof
显示不同的东西。例如,在x64架构的情况下,sizeof double
是8这是远离80bits。
为什么
std::numeric_limits< long double >::max()
给我1.18973e+4932
?!这是huuuuuuuuuge号码。如果这不是获得浮点数的最大值的方法,那么为什么会编译,甚至更多 - 为什么这会返回一个值。这是什么意思:
Double precision magnitudes can range from approximately 10^−308 to 10^308
这些庞大的数字,你不能把它们存储到8B甚至16B(这是扩展精度,这是只有128位)?
显然,我错过了一些东西。其实很明显,很多东西。
删除了“C”标签。 – 2011-05-12 16:29:32
阅读时间'每个计算机科学家应该知道什么关于浮点运算' – 2011-05-12 16:31:28
那么,只有'std :: numeric_limits'用于C++,而不是C.其他的东西都是相同的 - 讨论'float',双'和'长双',对吧? – 2011-05-12 16:32:17