473,659 Members | 2,839 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 10239
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
7233
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
17840
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
7100
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 decimal? That way the value would be 0.567800 again?
4
7842
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 long int to store the value, and the precision (number of decimal points) is variable (it's a templated class): template <size_t _decimal_places = 4> class FixedFloat {
1
2680
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, then assign this to a double, then subtract the double from the long, I get 0.
3
5430
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 have changed the state. I don't see the answer in Stroustrup or in the parashift FAQs. I would like to write a statement like my_ostream.restore_format_state_defaults();
2
3029
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
6589
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, for example, 3.1415926 . Or, in another way, how does the double presented in computer, and
2
2660
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
8427
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8332
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8525
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7356
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.