boostorg / boostorg/multiprecision
cpp_dec_float_100 can only be initialized precisely from a string? maybe should be documented, or what am I doing wrong?
- Dominant language
- C++
- Stars
- 265
- Forks
- 128
- Avg merge
- 4h 48m
- Merged PRs (30d)
- 2
Description
Just started using Boost.Multiprecision and struggled to get a cpp_dec_float_100 initialized to some hardcoded value. Eventually got it working once I parsed a string containing that hardcoded value. The docs didn't mention this I just sort of got lucky and deduced it.
Should this be documented?
Is there a better way to do it lol?
```
#include
#include "boost/multiprecision/cpp_dec_float.hpp"
int main(int argc, char *argv[])
{
using namespace std;
using namespace boost::multiprecision;
using EnormousFloat = cpp_dec_float_100;
EnormousFloat i = 6942666.123456789098765432123456789098765432199999999999999999999999999999999999999999999999999999999999999999;
cout << setprecision(numeric_limits::max_digits10) << i << endl;
//outputs: 6942666.12345678918063640594482421875
string buffer("6942666.123456789098765432123456789098765432199999999999999999999999999999999999999999999999999999999999999999");
istringstream is(buffer);
EnormousFloat parsed;
is >> parsed;
cout << setprecision(numeric_limits::max_digits10) << parsed << endl;
//outputs: the actual full value as above/desired
return 0;
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the initialization behavior in boost/multiprecision/cpp_dec_float.hpp and the existing Multiprecision documentation. Compare the direct floating-point initialization with the string-parsing example in the issue, then document the precise initialization guidance and clarify whether another supported approach exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100