473,503 Members | 10,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Default precision of cout

Dear all,

What is the default precision of cout for double types?(I think that
was 6 if I am not mistaken)

On the same cout statement I got(without any formatting)

0.00245579 0.00246217 80000
------------------------------------------------------
0.43077 0.022031 80000
------------------------------------------------------
0.425618 0.022031 80000
------------------------------------------------------
0.441189 0.022031 80000

The first line has 8 digits precision and the others have 6 or 5.

Regards,

Sep 5 '06 #1
2 10220
utab wrote:
Dear all,

What is the default precision of cout for double types?(I think that
was 6 if I am not mistaken)

On the same cout statement I got(without any formatting)
Where is the code that produced this output?
0.00245579 0.00246217 80000
------------------------------------------------------
0.43077 0.022031 80000
------------------------------------------------------
0.425618 0.022031 80000
------------------------------------------------------
0.441189 0.022031 80000

The first line has 8 digits precision and the others have 6 or 5.
No, the first line still only has 6 significant digits.
--
Clark S. Cox III
cl*******@gmail.com
Sep 5 '06 #2
utab wrote:
What is the default precision of cout for double types?(I think that
was 6 if I am not mistaken)
Yes, 6.
>
On the same cout statement I got(without any formatting)

0.00245579 0.00246217 80000
------------------------------------------------------
0.43077 0.022031 80000
------------------------------------------------------
0.425618 0.022031 80000
------------------------------------------------------
0.441189 0.022031 80000

The first line has 8 digits precision and the others have 6 or 5.
No, all have 6 digits of _precision_. The leading zeros do not count.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7220
by: TheFerryman | last post by:
Is there a convenient function for changing the precision of a float? (I have a bunch of floats that are currently printed out to 9 decimal places and I'd like them to printed out at about 4)
4
17821
by: {AGUT2} {H}-IWIK | last post by:
Hi, Is it possible to compare / output two numbers to a certain precision? for instance: #include <stdlib> #include <math> #include <iostream> #include <iomanip>
10
7080
by: Mad Butch | last post by:
void Test() { float fValue = 0.5678f; // Value is 0.567800 double dValue = (double)fValue; // Value is 0.56779998540878 } Is there anyway I can round a float at 6 positions behind the...
4
7827
by: Roger Leigh | last post by:
Hello, I'm writing a fixed-precision floating point class, based on the ideas in the example fixed_pt class in the "Practical C++ Programming" book by Steve Oualline (O' Reilly). This uses a...
1
2669
by: Nishant Deshpande | last post by:
On Solaris 64-bit: sizeof(long) = 8 sizeof(double) = 8 !!! So i figure i can't store a long with the same precision in a double. But, when i create a long and assign its largest value to it,...
3
5397
by: Matt | last post by:
Does the standard define default values for the format state of an ostream? I would like to be able to put a stream in a standard format state without thinking about how some other routine may...
2
3021
by: rupert | last post by:
i've got the following code: #include <iostream> #include <string> #include <vector> #include <iomanip> using namespace std; int main(double argc, char* argv) { double r = 0.01;
10
6573
by: Bo Yang | last post by:
Hi, I am confused by the double type in C++. I don't know whether below is legal or possible: double PI = 3.141592675932; Now, can I get another double variable from PI with lower precision,...
2
2651
by: whatdoineed2do | last post by:
#include <iostream> using namespace std; void convert(const double& d) { cout << "before=" << d << " after="; cout.precision(15); cout << d << endl; }
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7294
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7361
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7015
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5602
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4693
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3183
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1523
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.