Fix calculator appending extra zeros on non-en-US locales (#45624)

The C++ expression engine formatted results using the system locale,
which could produce comma decimal separators (e.g. "8,000000000000000").
The C# side then parsed this with en-US culture, interpreting commas as
thousands separators, turning 8 into 8000000000000000.

Fix: imbue the classic (C) locale on the output stream to always use
a dot decimal separator regardless of system locale.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Michael Jolley
2026-02-22 21:42:25 -06:00
parent 368490ef79
commit 1ac7fa302d

View File

@@ -28,6 +28,7 @@ namespace ExprtkCalculator::internal
std::wstring ToWStringFullPrecision(double value)
{
std::wostringstream oss;
oss.imbue(std::locale::classic());
oss << std::fixed << std::setprecision(15) << value;
return oss.str();
}