[RFC] moneypunct::frac_digits < 0 ?!?

Martin Sebor sebor@roguewave.com
Wed Mar 3 23:56:00 GMT 2004


Nathan Myers wrote:

...
> A consistent interpretation of negative frac_digits() is that you
> append extra zeroes at the end.  I.e., if you get "3", and it says
> -2 digits, you print "300".  If you parse "300", discard the last 
> two digits.  (Probably the standard should be clarified to require
> this behavior.)
> 
> This makes sense in dealing with massively inflated currencies, 
> when there is no information in the low digits.  (It might be
> invidious to suggest examples other than the Weimar mark.)
> 
...
 > BTW, since the standard doesn't say what happens for negative values,
 > the behavior is unspecified, and we're allowed to do almost anything.
 > After we get it deployed and demonstrate it works, we can write up
 > what we did, and submit it as "standardizing existing practice". :-)

Our implementation has a slightly different behavior in this case,
but only if ios::fixed is set: when frac_digits() is negative, we
take the absolute value of frac_digits() to be the precision of the
monetary value, including its fractional part. For instance, if
(frac_digits() == 3), the value 12.34 is formatted as 12.340, and
12.3456 as 12.345 by our money_put facet. This is just a side
effect of how we implement frac_digits in general and not a design
feature in its own right, but since this behavior is documented
changing it might cause us problems. I would be willing to support
your proposed behavior but only if ios::fixed is clear.

Martin



More information about the Libstdc++ mailing list