Mail Archives: djgpp/2003/07/19/23:52:46

From: "A. Sinan Unur" <asu1 AT c-o-r-n-e-l-l DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Doubles won't see double!!
Date: 20 Jul 2003 03:14:13 GMT
Organization: Cornell University
Lines: 50
Sender: asu1 AT cornell DOT invalid (on
Message-ID: <Xns93BDEC62AAAB9asu1cornelledu@>
References: <KrkSa.23882$pK2 DOT 37447 AT news DOT indigo DOT ie>
X-Trace: 1058670853 7821 (20 Jul 2003 03:14:13 GMT)
X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu
NNTP-Posting-Date: 20 Jul 2003 03:14:13 GMT
User-Agent: Xnews/5.04.25
X-Face: #0:Oa+WV[,\dU+SJ\X%#!MhGkG;vsj^Tzl1KJHck]V;S8u}yvJ<rd?.0]p2-6jgTf.>p~GpGgD.mLo)IY,&yDRM1dV3z'Y'8D=+Y7k[|[~mGbV(<(8Im%IhZkC9.A.&]TGcwX9GKGgA,lqReCST$aDsGKy#zU~laO|oJiD$e"6&_tzrxT}K,X_e,FC&}P8J"x~ii,lr6)L}=tZI#cNU,7u]J"TLISliDF2pmIKR`ulX=X-sB2aM?f4wIG5Z_nXceH~5}E*t+vx!unlkVJ7]57x`%S1\gR{.1_^Gu2L'am[/=c]'7Hj1l^Yx!nCe40dFkW
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Noel O'Donnell" <nodger AT eircom DOT net> wrote in
news:KrkSa.23882$pK2 DOT 37447 AT news DOT indigo DOT ie: 

> 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<<z;
> This will generally output something like:
> 3.1425(or whatever)
> however if I do the same sum on the windoze calculator:

ITYM division:

> get the
> picture 
> so my question is this: How can I make MY doubles behave like this?

Your doubles are behaving fine.

> is there a library that i need to include? any suggestions?

You need to set the appropriate options for cout.

#include <iomanip>
#include <iostream>

int main(void) {
	double x = 22;
	double y = 7;
	std::cout << std::setprecision(12) << x/y << std::endl;

A. Sinan Unur
asu1 AT c-o-r-n-e-l-l DOT edu
Remove dashes for address
Spam bait: mailto:uce AT ftc DOT gov

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019