471,045 Members | 950 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

nice printing 0 not -4.44e-14

Hi

I am expecting to get "0" (that is zero) printed but getting
"-2.7311e-14" almost zero. not nice for printing.

double a = \*...code calculations ...*\
some times a becomes a real, integer or natural number and I like it
to print in nice human read format.

cout << setw(20) << left << setprecision(5) << a;

thank you
Oct 27 '06 #1
1 1410

"Gary Wessle" <ph****@yahoo.comwrote in message
news:m3************@localhost.localdomain...
Hi

I am expecting to get "0" (that is zero) printed but getting
"-2.7311e-14" almost zero. not nice for printing.

double a = \*...code calculations ...*\
some times a becomes a real, integer or natural number and I like it
to print in nice human read format.

cout << setw(20) << left << setprecision(5) << a;
std::cout << std::fixed
<< std::setprecision(5)
<< std::left
<< std::setw(20)
<< a;

However, for numeric output, I generally prefer
std::right over std::left

-Mike
Oct 27 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Programatix | last post: by
reply views Thread by Programatix | last post: by
9 posts views Thread by Jody Gelowitz | last post: by
5 posts views Thread by Patrick De Ridder | last post: by
4 posts views Thread by Arif | last post: by

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.