次の 2 つのコードは、2 つの異なる出力を生成します。
//this one gives incorrect output
cpp_dec_float_50 x=log(2)
std::cout << std::setprecision(std::numeric_limits<cpp_dec_float_50>::digits)<< x << std::endl;
それが与える出力は
0.69314718055994528622676398299518041312694549560547
これは小数点以下 15 位までしか正しくありません。x が 2 倍だったとしても、最初の 15 桁は正しいはずです。結果はオーバーフローのようです。なぜそうすべきなのかわかりません。cpp_dec_float_50 の精度は 50 桁です。
//this one gives correct output
cpp_dec_float_50 x=2
std::cout << std::setprecision(std::numeric_limits<cpp_dec_float_50>::digits)<< log(x) << std::endl;
それが与える出力は
0.69314718055994530941723212145817656807550013436026
これは wolframaplha によると正しいです。