From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: Iostream question Date: 30 Apr 2001 13:25:51 GMT Organization: Aachen University of Technology (RWTH) Lines: 34 Message-ID: <9cjp4v$nps$1@nets3.rz.RWTH-Aachen.DE> References: <9cjlhq$3vf$1 AT info DOT cyf-kr DOT edu DOT pl> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 988637151 24380 137.226.32.75 (30 Apr 2001 13:25:51 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 30 Apr 2001 13:25:51 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Rafal Maj wrote: > Hi, > following code : > long double r = > 3.1415012345678901111112222233333444445555666677777888899999000012345; > cerr << setprecision(999) << r; > displays in cerr only : 3.1415012345678903 > How to display (or write to file) long double with full precision using > iostream ? Or does long double hold only 16 digits of my variable ? Long double holds more than 16 digits, but your way of initializing doesn't give it more than 16, I think. The problem is that your constant isn't flagged as a long double, and thus may be interpreted as a double. Try: long double r = 3.1415012345678901111112222233333L; There's no good reason to provide that many (or even more) digits --- even long double stores only around 20 (LDBL_EPSILON is 1.08e-19, roughly). The "L" suffix is important, because of this (taken from the C99 standard draft): [#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. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.