Mail Archives: djgpp/2001/06/29/06:30:06
Eli Zaretskii wrote:
> They work for me, in GCC 2.95.3. (I didn't use 2.95.2 long enough to
> tell.)
>
> For long doubles, the right format for debugging printf's is "%.19g".
^^^^ "%.19Lg"
right?
> 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.
so IMHO the libc info pages about printf/scanf are wrong.
(at least for DJGPP + gcc)
scanf():
`Le'
`LE'
`lle'
`llE'
`Lf'
`LF'
`llf'
`llF'
`Lg'
`LG'
`llg'
`llG'
Convert the input to a `long double'.
printf():
`e'
`E'
A floating point number (double or long double). The
exponent case matches the specifier case. The representation
always has an exponent.
`f'
A floating point number (double or long double). The
representation never has an exponent.
`g'
`G'
A floating point number (double or long double). The
exponent case matches the specifier case. The representation
has an exponent if it needs one.
--
Gruss Waldemar Schultz. schultz AT ma DOT tum DOT de
Technische Universität München, Zentrum Mathematik M1, D 80290 München
Tel: +49 (0)89 2892 8226 FAX: +49 (0)89 2892 8228
- Raw text -