long-double

long double (GCC specific) and __float128

大城市里の小女人 提交于 2019-11-26 10:35:09
问题 I\'m looking for detailed information on long double and __float128 in GCC/x86 (more out of curiosity than because of an actual problem). Few people will probably ever need these (I\'ve just, for the first time ever, truly needed a double ), but I guess it is still worthwile (and interesting) to know what you have in your toolbox and what it\'s about. In that light, please excuse my somewhat open questions: Could someone explain the implementation rationale and intended usage of these types,

can't print correctly a long double in C

倖福魔咒の 提交于 2019-11-26 09:57:43
问题 I am trying print a simple long double, but it doesn\'t work What I tried: long double ld=5.32; printf(\"ld with le = %Le \\n\",ld); printf(\"ld with lf = %Lf \\n\",ld); printf(\"ld with lg = %Lg \\n\",ld); Output: ld with le = -3.209071e-105 ld with lf = -0.000000 ld with lg = -3.20907e-105 With a new value: ld=6.72; Output: ld with le = -1.972024e+111 ld with lf = -1972024235903379200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000 ld with

long double vs double

筅森魡賤 提交于 2019-11-26 05:28:16
问题 I know that size of various data types can change depending on which system I am on. I use XP 32bits, and using the sizeof() operator in C++, it seems like long double is 12 bytes, and double is 8. However, most major sources states that long double is 8 bytes, and the range is therefore the same as a double. How come I have 12 bytes? If long double is indeed 12 bytes, doesn\'t this extends the range of value also? Or the long signature is only used (the compiler figures) when the value

printf and long double

我只是一个虾纸丫 提交于 2019-11-26 03:57:33
问题 I am using the latest gcc with Netbeans on Windows. Why doesn\'t long double work? Is the printf specifier %lf wrong? Code: #include <stdio.h> int main(void) { float aboat = 32000.0; double abet = 5.32e-5; long double dip = 5.32e-5; printf(\"%f can be written %e\\n\", aboat, aboat); printf(\"%f can be written %e\\n\", abet, abet); printf(\"%lf can be written %le\\n\", dip, dip); return 0; } Output: 32000.000000 can be written 3.200000e+004 0.000053 can be written 5.320000e-005