- Width- How much space is needed for the entire number
- Alignment - left or right- numbers tend to be right aligned
- Number of decimal places
- Sign or brackets for negative numbers.
- Thousands Separators. Big numbers look ugly without these.
Thousands separators are a little more complicated. They are set from the locale of a PC. A locale contains information relevant to your country- such as currency symbols and decimal point and thousands separators. In the UK and USA, the number 100.98 uses a decimal point . as the decimal point whereas in some European countries it is a comma so €5,70 means a price of 5 Euros and 70 cents.
int main()The output from this is
{
double a=925678.8750;
cout.setf(ios_base::showpoint|ios_base::right) ;
cout.fill('=') ;
cout.width(20) ;
locale loc("") ;
cout.imbue( loc ) ;
cout.precision(12) ;
cout << "The value is " << a << endl;
//cout.unsetf(ios_base::showpoint) ;
cout << left << "The value is " << a << endl;
for (int i=5;i< 12;i++) {
cout.precision(i) ;
cout << setprecision(i)<< "A= " << a << endl;
}
const moneypunct <char, true> &mpunct = use_facet <moneypunct <char, true > >(loc) ;
cout << loc.name( )<< mpunct.thousands_sep( ) << endl;
return 0;
}
=======The value is 925,678.875000
The value is 925,678.875000
A= 9.2568e+005
A= 925,679.
A= 925,678.9
A= 925,678.88
A= 925,678.875
A= 925,678.8750
A= 925,678.87500
English_United Kingdom.1252,
On the Next Page More about Locale

