From: Jason Green Newsgroups: comp.os.msdos.djgpp Subject: Re: Iostream question Date: Wed, 02 May 2001 23:46:16 +0100 Lines: 49 Message-ID: References: <9cjlhq$3vf$1 AT info DOT cyf-kr DOT edu DOT pl> <9cjp4v$nps$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> NNTP-Posting-Host: modem-154.xenon.dialup.pol.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: newsg2.svr.pol.co.uk 988843556 6150 62.136.45.154 (2 May 2001 22:45:56 GMT) NNTP-Posting-Date: 2 May 2001 22:45:56 GMT X-Complaints-To: abuse AT theplanet DOT net X-Newsreader: Forte Agent 1.7/32.534 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hans-Bernhard Broeker wrote: > Rafal Maj wrote: > > following code : > > long double r = > > 3.1415012345678901111112222233333444445555666677777888899999000012345; > > cerr << setprecision(999) << r; > > displays in cerr only : 3.1415012345678903 Hmmm, interesting bug. #include #include 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.