Number Fomatting

U

utab

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.
 
A

Abdo Haji-Ali

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
 
I

Ian Collins

utab said:
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)
 
A

Abdo Haji-Ali

so I want to limit the width of these numbers as 8 while preserving the
See std::setiosflags() and setprecision()

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

Abdo Haji-Ali
Programmer
In|Framez
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top