Skip to content

Commit

Permalink
Merge pull request #60 from jensyt/master
Browse files Browse the repository at this point in the history
Correct output to stream after decimal place when a locale has been set.
  • Loading branch information
vpiotr authored Dec 14, 2023
2 parents 98265a5 + 1eda2e9 commit 4e85393
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1705,8 +1705,8 @@ decimal<Prec, RoundPolicy> decimal_cast(const char (&arg)[N]) {
output << "-";
}

std::locale oldloc = output.getloc();
if (format.thousands_grouping() && format.change_thousands_if_needed()) {
std::locale oldloc = output.getloc();
output.imbue( std::locale( std::locale::classic(), new decimal_format_punct(format) ) );
output << before;
output.imbue(oldloc);
Expand All @@ -1715,9 +1715,11 @@ decimal<Prec, RoundPolicy> decimal_cast(const char (&arg)[N]) {
}

if (arg.getDecimalPoints() > 0) {
output.imbue(std::locale::classic());
output << format.decimal_point();
output << setw(arg.getDecimalPoints()) << setfill('0') << right
<< after;
output.imbue(oldloc);
}
}

Expand Down

0 comments on commit 4e85393

Please sign in to comment.