Mail Archives: djgpp/2001/06/29/03:22:12
> From: invalid AT erehwon DOT invalid (Graaagh the Mighty)
> Newsgroups: comp.os.msdos.djgpp
> Date: Thu, 28 Jun 2001 15:41:40 GMT
>
> Long doubles seem to be broken in gcc 2.95.2 anyway
They work for me, in GCC 2.95.3. (I didn't use 2.95.2 long enough to
tell.)
> -- at
> least, when I wrote the stuff I am working on it initially used long
> doubles, and gave bogus results; adding debugging printfs I discovered
> that some values were strangely becoming zeroes that shouldn't have
> been. It worked when I changed every occurrence of "long double" to
> "ldouble", then typedef'd that as "double". Change the typedef to
> "long double" and the zeros reappear.
This is usually a sign of a numeric bug in the code.
> (Actually, I tend to use
> "%1.16f" when debugging FP code, since the default "%f" gives only
> "float" precision output even when doubles and long doubles are
> passed. Clearly this should work fine with long doubles, except that
> even 16 digits of precision might not be enough for many cases.)
For long doubles, the right format for debugging printf's is "%.19g".
Note: "g", not "f", because you want 19 significant digits, not 19
digits after the dot (think about a number like 123456789.987654321).
For the same reason, I suggest to use "%.16g" for doubles.
> I am somewhat curious as to how printf
> knows the format of a double or for that matter int you pass it
> however.
It doesn't; it simply assumes that the format specifier tells the
truth. That is, if you say "%f", the corresponding argument is a
double, and if you say "%Lf", it's a long double.
- Raw text -