CS 150 Introduction to C++
Programming - Spring 1998
|
[ Home | Lecture
Notes| WebTutor | WebTutor
Site Map]
Formatting Output for Floating Point Numbers
The output of numbers
is controlled by IO Manipulators. Two
common manipulators for the output are
- setw(n), which sets the fieldwidth to
the integer "n"
- If "n" is bigger than the item for
output, blanks are inserted on the left
- If "n" is smaller than the item for
output, "n" is increased to the minimum
necessary to output.
- setw is only in effect for the next item for
output.
- setw(0) means use the minimum space necessary to
output the item.
- setprecision(n), which sets the number
of digits after the decimal point to the integer
"n"
- setprecision stays in effect until another
setprecision changes the number of decimal
places.
Copyright chris wild 1998.
For problems or questions regarding this web contact [Dr. Wild (e-mail:wild@cs.odu.edu].
Last updated: February 04, 1998.