/*Orion Lawlor's Simple STL Examples, olawlor@acm.org
Shows how to use std::ostream "manipulator" objects.
*/
#include <iostream>
#include <iomanip>

int main()
{
	int i=127;
	double d=3.4567890123456789;
	
	std::cout<<"\n Precision:\n";
	std::cout<<"default:  |"<<                       d<<"|\n";
	std::cout<<"10-digit: |"<<std::setprecision(10)<<d<<"|\n";
	std::cout<<"20-digit: |"<<std::setprecision(20)<<d<<"|\n";
	std::cout<<"un-set:   |"<<                       d<<"|\n";
	std::cout<<std::setprecision(7); // reset precision to default
	std::cout<<"reset:    |"<<                       d<<"|\n";
	
	std::cout<<"\n Field width:\n";
	std::cout<<"default:         |"<<                              d<<"|\n";
	std::cout<<"left justified:  |"<<std::left    <<std::setw(40)<<d<<"|\n";
	std::cout<<"right justified: |"<<std::right   <<std::setw(40)<<d<<"|\n";
	std::cout<<"int. justified:  |"<<std::internal<<std::setw(40)<<d<<"|\n";
	std::cout<<"pad with X's:    |"<<std::internal<<
		std::setfill('X')<<std::setw(40)<<d<<"|\n";
	std::cout<<std::left<<std::setfill(' '); // reset field width to default
	
	std::cout<<"\n Fixed/scientific:\n";
	std::cout<<"default:     |"<<                 d<<"|\n";
	std::cout<<"fixed:       |"<<std::fixed     <<d<<"|\n";
	std::cout<<"scientific:  |"<<std::scientific<<d<<"|\n";
	
	std::cout<<"\n Dec/hex/oct:\n";
	std::cout<<"default: |"<<i<<"|\n";
	std::cout<<"hex:     |"<<std::hex<<i<<"|\n";
	std::cout<<"oct:     |"<<std::oct<<i<<"|\n";
	std::cout<<"dec:     |"<<std::dec<<i<<"|\n";
	
	return 0;
}
/*<@>
<@> ******** Program output: ********
<@> 
<@>  Precision:
<@> default:  |3.45679|
<@> 10-digit: |3.456789012|
<@> 20-digit: |3.4567890123456788132|
<@> un-set:   |3.4567890123456788132|
<@> reset:    |3.456789|
<@> 
<@>  Field width:
<@> default:         |3.456789|
<@> left justified:  |3.456789                                |
<@> right justified: |                                3.456789|
<@> int. justified:  |                                3.456789|
<@> pad with X's:    |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX3.456789|
<@> 
<@>  Fixed/scientific:
<@> default:     |3.456789|
<@> fixed:       |3.4567890|
<@> scientific:  |3.4567890e+00|
<@> 
<@>  Dec/hex/oct:
<@> default: |127|
<@> hex:     |7f|
<@> oct:     |177|
<@> dec:     |127|
<@> */
