473,412 Members | 3,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

setting and resetting stream precision

Hi, I would like to save a stream's output precision and then change the
precision and then restore it. One example I found was using
ios_base::fixed, and ios_base::floatfield. But on my machine this only
gives 6 or 8 digits after the decimal. I would like at least 12. If I do
cout.precision(12), then cout is forever set to 12 precisions from that
point on. I guess I can call cout.precision(4) when I'm done, but how do I
know that 4 is the default?

example:
ios_base::fmtflags f = cout.flags();
cout.setf(ios_base::fixed, ios_base::floatfield);
cout << 12.5123123123123123123123123123 << endl;
cout.flags(f);
cout << 12.5123123123123123123123123123 << endl;

Thanks in advance.
Jul 19 '05 #1
1 5370
On Tue, 5 Aug 2003 11:33:14 -0400, "john smith" <as**@asdf123asdf.net>
wrote:
Hi, I would like to save a stream's output precision and then change the
precision and then restore it. One example I found was using
ios_base::fixed, and ios_base::floatfield. But on my machine this only
gives 6 or 8 digits after the decimal. I would like at least 12. If I do
cout.precision(12), then cout is forever set to 12 precisions from that
point on. I guess I can call cout.precision(4) when I'm done, but how do I
know that 4 is the default?

example:
ios_base::fmtflags f = cout.flags();
cout.setf(ios_base::fixed, ios_base::floatfield);
cout << 12.5123123123123123123123123123 << endl;
cout.flags(f);
cout << 12.5123123123123123123123123123 << endl;


http://www.boost.org/libs/io/doc/ios_state.html

Tom
Jul 19 '05 #2

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

Similar topics

1
by: Thomas Chassaing | last post by:
Hi, I just installed the mxNumber package and looking trough the documentation I found no means to set the default precision for Float numbers (I think it is set to 64bits). Does anyone know how...
3
by: John Flynn | last post by:
hi, having problems reading from and writing back to the same file. basically, i want to read lines of text from a file and reverse them and write them back to the same file.. it has to...
3
by: jjleto | last post by:
I want to reset an ostringstream so that: ostringstream oss; oss << "foo "; cout << oss.str(); // what should go here ? oss << "bar"; cout << oss.str(); issues
5
by: Riku Jarvinen | last post by:
Hi everyone, I asked another question regarding this same subject about a week ago. See thread: ...
1
by: simon | last post by:
I have an unbound RTF2 control in an Access 2003 form which I set to show either unformatted text or else text with words and sentences highlighted. I do this by setting the PlainText property,...
4
by: Ian Davies | last post by:
Hello I am struggling for a solution to clear some fields on my webpage that takes their values from some sessions My solution below works when the button is clicked twice. I sort of know why I...
0
by: John Friedland | last post by:
'printf' allows an integer to be printed with a precision. "printf("|%5.2d|", 1)", for example, produces "| 01|". This doesn't seem to be possible with stream I/O - 'precision' only seems to...
4
by: Bob | last post by:
I'm just starting PHP and MySQL - and really like the book by Welling and Thomsom. I've installed MySQL on my WinXP desktop, along with Apache and PHP. I have not figured out how to set a...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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...
0
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...

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.