Division with boost::multiprecision::cpp_dec_float
have some kind of rounding error, as follows:
#include <iostream>
#include <boost/multiprecision/cpp_dec_float.hpp>
using my_t = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<20, std::int32_t>>;
int main()
{
my_t a = 150;
my_t b = 300;
my_t c = a / b;
std::cout << c.str() << std::endl;
std::cout << ((c==my_t(0.5))?"==":"!=") << std::endl;
return 0;
}
Output:
0.5000000000000000000000000000000000000000136852
!=
Is this expected?
Are there other types which are more appropriate, considering a really need the decimal value?
Am i expected to truncate or round to a magical number of decimal digits?