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

Nathan Myers ncm-nospam@cantrip.org
Wed Mar 3 14:55:00 GMT 2004

On Wed, Mar 03, 2004 at 03:37:09PM +0100, Paolo Carlini wrote:
> speaking of corner cases, this is one: according to the standard,
> frac_digits() returns an int... "of course" ;) in our current
> implementation we don't deal gracefully with frac_digits() < 0 (*)
> So, what shall we do? Consistency with other sections of the
> standard (i.e., num_put::do_put for negative precision) and Note
> 244 seem to suggest that we should use by "default" the value 2...

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.)

Nathan Myers

More information about the Libstdc++ mailing list