在Mac OS X 10.6.2,Intel,使用i686-apple-darwin10-g ++ - 4.2.1,并使用-arch x86_64标志进行编译时,我注意到了......
std::numeric_limits<long double>::max_exponent10 = 4932...正如预期的那样,当long double实际设置为指数大于308的值时,它变为inf - 即实际上它只有64位精度而不是80位。
此外, sizeof()显示长双精度为16字节,它们应该是。
最后,使用<limits.h>给出与<limits>相同的结果。
有谁知道差异可能在哪里?
long double x = 1e308, y = 1e309; cout << std::numeric_limits<long double>::max_exponent10 << endl; cout << x << '\t' << y << endl; cout << sizeof(x) << endl;给
4932 1e + 308 inf 16
Working on Mac OS X 10.6.2, Intel, with i686-apple-darwin10-g++-4.2.1, and compiling with the -arch x86_64 flag, I just noticed that while...
std::numeric_limits<long double>::max_exponent10 = 4932...as is expected, when a long double is actually set to a value with exponent greater than 308, it becomes inf--ie in reality it only has 64bit precision instead of 80bit.
Also, sizeof() is showing long doubles to be 16 bytes, which they should be.
Finally, using <limits.h> gives the same results as <limits>.
Does anyone know where the discrepancy might be?
long double x = 1e308, y = 1e309; cout << std::numeric_limits<long double>::max_exponent10 << endl; cout << x << '\t' << y << endl; cout << sizeof(x) << endl;gives
4932 1e+308 inf 16
最满意答案
这是因为1e309是一个双倍的文字。 你需要使用long-double literal 1e309L 。
It's because 1e309 is a literal that gives a double. You need to use a long-double literal 1e309L.
更多推荐
发布评论