467,879 Members | 1,213 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,879 developers. It's quick & easy.

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
  • viewed: 1334
Share:
1 Reply

"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 this site, you agree to our Privacy Policy and Terms of Use.