Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old September 25th, 2006, 01:15 AM
Wing
Guest
 
Posts: n/a
Default 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.

  #2  
Old September 25th, 2006, 01:55 AM
Victor Bazarov
Guest
 
Posts: n/a
Default Re: scientific computation

Wing wrote:
Quote:
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


  #3  
Old September 25th, 2006, 07:35 PM
Jacek Dziedzic
Guest
 
Posts: n/a
Default Re: scientific computation

Wing wrote:
Quote:
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.
  #4  
Old September 25th, 2006, 10:05 PM
Marcus Kwok
Guest
 
Posts: n/a
Default Re: scientific computation

Jacek Dziedzic <jacek@no_spam.tygrys.no_spam.netwrote:
Quote:
Wing wrote:
Quote:
>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
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles