"Nick Hounsome" <nh***@blueyonder.co.uk> wrote in message news:<6i***************@news-binary.blueyonder.co.uk>...
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:UIpYb.48734$jk2.116305@attbi_s53... "Tommi Mäkitalo" <t.*********@epgmbh.de> wrote... I need to format floating-point-numbers with exact 2 digits after decimal point. I could use printf with "%.2f", but it don't use std::locale.
Any ideas?
Take a look at 'fixed' and other field flags from <ios>. They do
not use 'locale', IIRC.
Anybody have any idea why the std has support (or at least hooks) for
formatting money in a
locale dependent way and yet has no class that makes use of it?
It's the same in C...LC_MONETARY was provided for choosing specific
monetary formats with setlocale(), then you could use localconv() to
get the currency_symbol etc. etc. But you had to do all the work
yourself, including grouping, decimal point selection (if different to
decimal point for non-monetry selection) etc. etc. It would seem
obvious enough to have printf-support printing monetary values, or
indeed formatting according to locale-conventions, and even proper
parsing (only the decimal point specifier is actually used by
atof/strtod - you can't use thousands grouping or different sign
formats). Of course there is strfmon, but no part of standard C, only
POSIX (I believe).
Dylan