No scientific notation?

V

Ville Ahonen

I'm a total beginner at C++ so please bear with me.. When i write

cout << stddev * stddev << endl;

I get the output "4.49513e-05". How can I rephrase the above so that I
would instead get the output "0.000049513"?

Thanks alot,

Ville
 
J

John Harrison

Ville Ahonen said:
I'm a total beginner at C++ so please bear with me.. When i write

cout << stddev * stddev << endl;

I get the output "4.49513e-05". How can I rephrase the above so that I
would instead get the output "0.000049513"?

cout << fixed << stddev*stddev << endl;

john
 
M

Mike Wahler

John Harrison said:
cout << fixed << stddev*stddev << endl;

To elaborate:

You can also use 'setprecision(n)' to control the
number of digits after the decimal point.

'std::fixed' is declared by <ios>, and
'std::setprecision()' is declared by <iomanip>

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top