By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 986 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

Number Fomatting

P: n/a
Hi there,

I have double values x, y and z like the ones below

1.19809 0.465934 0.0197982

so I want to limit the width of these numbers as 8 while preserving the
maximum available precision. Does the standard library have something
to do with these kinds of operations?

For example for this particular problem, the last number is 9
characters wide and I would like to present that as 0.019798.

Thanks in advance.

Apr 12 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
> 1.19809 0.465934 0.0197982

so I want to limit the width of these numbers as 8 while preserving the
maximum available precision. Does the standard library have something
to do with these kinds of operations?

For example for this particular problem, the last number is 9
characters wide and I would like to present that as 0.019798.


See std::setiosflags() and setprecision()

Abdo Haji-Ali
Programmer
In|Framez

Apr 12 '06 #2

P: n/a
utab wrote:
Hi there,

I have double values x, y and z like the ones below

1.19809 0.465934 0.0197982

so I want to limit the width of these numbers as 8 while preserving the
maximum available precision. Does the standard library have something
to do with these kinds of operations?

For example for this particular problem, the last number is 9
characters wide and I would like to present that as 0.019798.


Have a look at the standard manipulators setw(int) and setprecision(int)

--
Ian Collins.
Apr 12 '06 #3

P: n/a
> > so I want to limit the width of these numbers as 8 while preserving the
maximum available precision. Does the standard library have something
to do with these kinds of operations?

For example for this particular problem, the last number is 9
characters wide and I would like to present that as 0.019798.


See std::setiosflags() and setprecision()


Sorry a typo, I meant setiosflags() (without the std) and
setprecision()

Abdo Haji-Ali
Programmer
In|Framez

Apr 12 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.