From: "Noel O'Donnell" Newsgroups: comp.os.msdos.djgpp References: Subject: Re: Doubles won't see double!! Lines: 61 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Mon, 21 Jul 2003 22:05:45 +0100 NNTP-Posting-Host: 159.134.113.51 X-Complaints-To: abuse AT eircom DOT net X-Trace: news.indigo.ie 1058821538 159.134.113.51 (Mon, 21 Jul 2003 22:05:38 BST) NNTP-Posting-Date: Mon, 21 Jul 2003 22:05:38 BST Organization: Eircom.Net http://www.eircom.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com thx guys...i like the look of these "long doubles" "Martin Ambuhl" wrote in message news:Xns93BE42C022A7mambuhlearthlinknet AT 207 DOT 217 DOT 77 DOT 26... > "Noel O'Donnell" wrote (18 Jul 2003) in > news:KrkSa.23882$pK2 DOT 37447 AT news DOT indigo DOT ie / comp.os.msdos.djgpp: > > > Hello all, > > > > Just wondering this: > > How can I perform maths on doubles, so that the result uses the > > full potential of a double's decimal spaces? > > > > confused? ok, perhaps an example: > > > > double x,y,z; > > x=22; > > y=7; > > z=x/y; > > cout< > > > This will generally output something like: > > 3.1425(or whatever) > > however if I do the same sum on the windoze calculator: > > 3.142857142957142857...................................you get the > > picture > > > > so my question is this: How can I make MY doubles behave like > > this? is there a library that i need to include? any suggestions? > > In C++ the , the ios_base classes have member functions precision() > and width(); also provides setprecision and setw > manipulators. Your C++ text should give you the information you > need. Below is an example of accomplishing this in C: > > #include > #include > > int main(void) > { > double x = 22, y = 7; > long double xl = 22, yl = 7; > float xf = 22, yf = 7; > printf("double result: %.*g\n", DBL_DIG, x / y); > printf("long double result: %.*Lg\n", LDBL_DIG, xl / yl); > printf("float result: %.*g\n", FLT_DIG, xf / yf); > return 0; > } > > > double result: 3.14285714285714 > long double result: 3.14285714285714286 > float result: 3.14286 > > > -- > Martin Ambuhl > Returning soon to the > Fourth Largest City in America