Boost logo

Boost :

From: tom brinkman (reportbase_at_[hidden])
Date: 2004-09-06 09:07:10


Check out ::strfmon

http://www.opengroup.org/onlinepubs/009695399/functions/strfmon.html

EXAMPLES

Given a locale for the U.S. and the values 123.45, -123.45, and 3456.781,
the following output might be produced. Square brackets ( "[]" ) are used
in this example to delimit the output.

 
%n [$123.45] Default formatting
           [-$123.45]
           [$3,456.78]

%11n [ $123.45] Right align within an 11-character field
           [ -$123.45]
           [ $3,456.78]

%#5n [ $ 123.45] Aligned columns for values up to 99999
           [-$ 123.45]
           [ $ 3,456.78]

%=*#5n [ $***123.45] Specify a fill character
           [-$***123.45]
           [ $*3,456.78]

%=0#5n [ $000123.45] Fill characters do not use grouping
           [-$000123.45] even if the fill character is a digit
           [ $03,456.78]

%^#5n [ $ 123.45] Disable the grouping separator
           [-$ 123.45]
           [ $ 3456.78]

%^#5.0n [ $ 123] Round off to whole units
           [-$ 123]
           [ $ 3457]

%^#5.4n [ $ 123.4500] Increase the precision
           [-$ 123.4500]
           [ $ 3456.7810]

%(#5n [$ 123.45] Use an alternative pos/neg style
           [($ 123.45)]
           [$ 3,456.78]

%!(#5n [ 123.45] Disable the currency symbol
           [( 123.45)]
           [ 3,456.78]

%-14#5.4n [ $ 123.4500 ] Left-justify the output
           [-$ 123.4500 ]
           [ $ 3,456.7810 ]

%14#5.4n [ $ 123.4500] Corresponding right-justified output
           [ -$ 123.4500]
           [ $ 3,456.7810]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk