When the monetary value is zero, std::put_money doesn't output the '0' character as expected. I can't find anything explaining this behaviour.
example:
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
cout.imbue(locale(""));
cout << showbase << put_money(0.0);
return 0;
}
I would expect the output to be "£0.00" (dependant on locale) but instead I get "£.00"
Ultimately, it's not too troublesome adding a special case for zero values, but this behaviour still doesn't make sense to me. What's the reason for this (presuming it's intentional), and other than handling zero separately, are there any simple workarounds?
Update
This seems compiler specific, I've had reports that it works as expected with clang and VS, so probably gcc/g++ specific (version 4.9 to be precise, but other versions seem to show the same behaviour)
د.ت. .000
and₪ .00
, but¥0
and₩0
. – Hoecake