| Summary: | dev-libs/boost-1.79.0: cpp_dec_float<>::convert_to<double>() fails when locale radix character is ',' | ||
|---|---|---|---|
| Product: | Gentoo Linux | Reporter: | Marcus Comstedt <marcus> |
| Component: | Current packages | Assignee: | David Seifert <soap> |
| Status: | RESOLVED OBSOLETE | ||
| Severity: | normal | CC: | jstein, orzel, sam |
| Priority: | Normal | Keywords: | PATCH |
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | Linux | ||
| See Also: | https://github.com/boostorg/multiprecision/issues/464 | ||
| Whiteboard: | |||
| Package list: | Runtime testing required: | --- | |
| Attachments: | Upstreams patch, with filenames modified to match the unified boost dist | ||
Created attachment 793847 [details, diff]
Upstreams patch, with filenames modified to match the unified boost dist
Sorry, I'd meant to apply this earlier, although will likely be sorted w/ 1.80 now. |
When the current locale uses ',' as the radix character instead of '.', the result of cpp_dec_float<>::convert_to<double>() is incorrect. Test program: --8<-- #include <iostream> #include <boost/multiprecision/cpp_dec_float.hpp> #include <locale.h> #include <langinfo.h> int main() { double x1 = 987.654; boost::multiprecision::number< boost::multiprecision::cpp_dec_float<24>, boost::multiprecision::et_off> x2 = x1; setlocale(LC_NUMERIC, "C"); std::cout << "radixchar is " << nl_langinfo(RADIXCHAR) << std::endl; std::cout << x1 << std::endl; std::cout << x2 << std::endl; std::cout << x2.convert_to<double>() << std::endl << std::endl; setlocale(LC_NUMERIC, "sv_SE.utf8"); std::cout << "radixchar is " << nl_langinfo(RADIXCHAR) << std::endl; std::cout << x1 << std::endl; std::cout << x2 << std::endl; std::cout << x2.convert_to<double>() << std::endl << std::endl; return 0; } --8<-- Output: --8<-- radixchar is . 987.654 987.654 987.654 radixchar is , 987.654 987.654 9 ---8<--- The expected result is the same number is printed in all six cases. Upstreams issue and fix: https://github.com/boostorg/multiprecision/issues/464