I am using .str(n, std::ios_base::scientific)
to print ccp_dec_float
s.
I've noticed that it rounds up.
I am using cpp_dec_float
for accounting, so I need to round downward. How can this be done?
I am using .str(n, std::ios_base::scientific)
to print ccp_dec_float
s.
I've noticed that it rounds up.
I am using cpp_dec_float
for accounting, so I need to round downward. How can this be done?
I assume you're trying to achieve rounding to a certain decimal point, correct?
Standard rounding
But as your title says, you're trying to force it to round down, so consider
Good luck!
It doesn't round up. In fact, it does banker's round: See it Live On Coliru
Prints:
So if you want another kind of rounding, you'd want to write it explicitly
Here's a generic approach (Live On Coliru)
which hopefully compiles down to optimal code due to statically known scale factor and the use of expression templates in Boost Multiprecision library.