boostorg / boostorg/multiprecision

Convert to string using current locale settings.

Open
#99 18 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
265
Forks
128
Avg merge
4h 48m
Merged PRs (30d)
2

Description

I can't find how to convert a cpp_dec_float_50 to a string with the current regional settings (in my case: '.' for digit grouping symbol and ',' for decimal symbol). Looking through the format_float_string function in detail/number_base it seems like it always inserts '.' as a decimal symbol.
Also posted this to [StackOverflow](https://stackoverflow.com/questions/53496971/converting-boost-multiprecision-to-a-string-with-current-locale-settings).

This is what I get with a regular double:
```
double d = 1494.33;
std::stringstream ss;
ss.imbue(std::locale(""));
ss << std::fixed << std::setprecision(6) << d;
std::cout << ss.str() << std::endl;
```
outputs 1.494,330000

Trying the same with dec_float:
```
boost::multiprecision::cpp_dec_float_50 df = 1494.33;
std::stringstream ss;
ss.imbue(std::locale(""));
ss << std::fixed << std::setprecision(6) << df;
std::cout << ss.str() << std::endl;
```
outputs 1494.330000

Is there any way to get a regional string out of a boost::multiprecision?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.