473,408 Members | 1,821 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,408 software developers and data experts.

scientific computation

Hello eveyone,

I am programming some scientific computation based on C++. I would like
to set every output/input (e.g. cout, io file stream) to be a high
precision.

What C++ command should I use?

Thanks so much.

Sep 25 '06 #1
3 2612
Wing wrote:
I am programming some scientific computation based on C++. I would
like to set every output/input (e.g. cout, io file stream) to be a
high precision.

What C++ command should I use?
You need to read about 'setprecision', my guess would be.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 25 '06 #2
Wing wrote:
Hello eveyone,

I am programming some scientific computation based on C++. I would like
to set every output/input (e.g. cout, io file stream) to be a high
precision.

What C++ command should I use?
First, #include<iomanip>.

Then choose fixed-point output (cout << fixed;)
or scientific-notation output (cout << scientific;).

Finally tell the output stream how many digits of precision
you require, eg. for 12 try

cout << setprecision(12);

That's basically it. For more details read up on "manipulators".

HTH,
- J.
Sep 25 '06 #3
Jacek Dziedzic <jacek@no_spam.tygrys.no_spam.netwrote:
Wing wrote:
>Hello eveyone,

I am programming some scientific computation based on C++. I would like
to set every output/input (e.g. cout, io file stream) to be a high
precision.

What C++ command should I use?

First, #include<iomanip>.

Then choose fixed-point output (cout << fixed;)
or scientific-notation output (cout << scientific;).

Finally tell the output stream how many digits of precision
you require, eg. for 12 try

cout << setprecision(12);

That's basically it. For more details read up on "manipulators".
Also, the OP may want to investigate the use of
std::numeric_limits<T>::digits10 (requires #include <limits>), which
will give "the number of decimal digits that the type can represent
without change" (quote from Dinkumware documentation:
http://www.dinkumware.com/manuals/?m...its::digits10).

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Sep 25 '06 #4

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

Similar topics

22
by: Michael Gorbach | last post by:
I was asked this summer to write a monte carlo code to simulation magnetic nanoparticles. For the nonphysicists, basicly it is a simulation where most of the time is taken up by looping through...
0
by: Greg | last post by:
I am working on an application that requires working with numbers in scientific notation. I am using SqlServer as the database and I have created strongly typed data adapters and datasets. The...
53
by: Michael Tobis | last post by:
Someone asked me to write a brief essay regarding the value-add proposition for Python in the Fortran community. Slightly modified to remove a few climatology-related specifics, here it is. I...
0
by: Juan R. | last post by:
I have updated some basic requirements for a generic mathematical markup language for scientific requirements at the next link. ...
9
by: Joe Attardi | last post by:
Hi all, Math is not my strongest area so forgive me if I use some of the wrong terminology. It seems that scientific notation is immune to rounding errors. For example: (4.98 * 100) + 5.51 ...
2
by: Greg | last post by:
I am working on an application that requires working with numbers in scientific notation. I am using SqlServer as the database and I have created strongly typed data adapters and datasets. The...
2
by: asdf | last post by:
Is there any forum or group which discusses the scientific computation in C++?
43
by: parallelpython | last post by:
Has anybody tried to run parallel python applications? It appears that if your application is computation-bound using 'thread' or 'threading' modules will not get you any speedup. That is because...
14
by: Luna Moon | last post by:
Dear all, Can C++/STL/Boost do the vectorized calculation as those in Matlab? For example, in the following code, what I really want to do is to send in a vector of u's. All other...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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
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...

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.