Mail Archives: djgpp/2001/05/02/20:39:09
Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de> wrote:
> Rafal Maj <maj_rafal AT poczta DOT onet DOT pl> wrote:
> > following code :
> > long double r =
> > 3.1415012345678901111112222233333444445555666677777888899999000012345;
> > cerr << setprecision(999) << r;
> > displays in cerr only : 3.1415012345678903
Hmmm, interesting bug.
#include <iostream>
#include <iomanip>
int main()
{
long double r =
3.1415012345678901111112222233333444445555666677777888899999000012345;
int i;
for (i=1; i<2000; i++)
cerr << i << " " << setprecision(i) << r << endl;
}
> > How to display (or write to file) long double with full precision using
> > iostream ?
Try setprecision(998) or setprecision(1000) :-)
> Or does long double hold only 16 digits of my variable ?
It will hold more than that, but not necessarily the exact value that you
assign it.
> Try:
>
> long double r = 3.1415012345678901111112222233333L;
> [#4] An unsuffixed floating constant has type double. If
> suffixed by the letter f or F, it has type float. If
> suffixed by the letter l or L, it has type long double.
Well if that's what the standard says... ;-). FWIW, adding the L suffix
seems to make no difference.
Roll on gcc 3.0.
- Raw text -