Electrical and Computer Engineering
17 of 52
UAH
CPE 112
Manipulating
Floating-Point Numbers
•setw also works with floating-point numbers (remember that a decimal point is a character)
•If you don’t want numbers to appear in scientific notation, use fixed.
•If you want whole numbers printed with a .0 appended, use showpoint.
•If you want to control the number of decimal places that are displayed, use setprecision(n), where n is the number of decimal places desired. Unlike setw, setprecision stays in effect until you explicitly change it.