@@ -98,7 +98,7 @@ namespace local
9898 auto dis_r =
9999 std::uniform_real_distribution<float_type>
100100 {
101- static_cast <float_type>(1 .2L ),
101+ static_cast <float_type>(1 .4L ),
102102 static_cast <float_type>(8 .9L )
103103 };
104104
@@ -294,6 +294,75 @@ namespace local
294294 return result_is_ok;
295295 }
296296
297+ auto test_log10_128 (const int tol_factor) -> bool
298+ {
299+ using decimal_type = boost::decimal::decimal128;
300+
301+ using str_ctrl_array_type = std::array<const char *, 28U >;
302+
303+ const str_ctrl_array_type ctrl_strings =
304+ {{
305+ // Table[N[Log[10, 456 10^n], 36], {n, -3, 24, 1}]
306+ " -0.341035157335565015527421936814476293" ,
307+ " 0.658964842664434984472578063185523707" ,
308+ " 1.65896484266443498447257806318552371" ,
309+ " 2.65896484266443498447257806318552371" ,
310+ " 3.65896484266443498447257806318552371" ,
311+ " 4.65896484266443498447257806318552371" ,
312+ " 5.65896484266443498447257806318552371" ,
313+ " 6.65896484266443498447257806318552371" ,
314+ " 7.65896484266443498447257806318552371" ,
315+ " 8.65896484266443498447257806318552371" ,
316+ " 9.65896484266443498447257806318552371" ,
317+ " 10.6589648426644349844725780631855237" ,
318+ " 11.6589648426644349844725780631855237" ,
319+ " 12.6589648426644349844725780631855237" ,
320+ " 13.6589648426644349844725780631855237" ,
321+ " 14.6589648426644349844725780631855237" ,
322+ " 15.6589648426644349844725780631855237" ,
323+ " 16.6589648426644349844725780631855237" ,
324+ " 17.6589648426644349844725780631855237" ,
325+ " 18.6589648426644349844725780631855237" ,
326+ " 19.6589648426644349844725780631855237" ,
327+ " 20.6589648426644349844725780631855237" ,
328+ " 21.6589648426644349844725780631855237" ,
329+ " 22.6589648426644349844725780631855237" ,
330+ " 23.6589648426644349844725780631855237" ,
331+ " 24.6589648426644349844725780631855237" ,
332+ " 25.6589648426644349844725780631855237" ,
333+ " 26.6589648426644349844725780631855237" ,
334+ }};
335+
336+ std::array<decimal_type, std::tuple_size<str_ctrl_array_type>::value> log_values { };
337+ std::array<decimal_type, std::tuple_size<str_ctrl_array_type>::value> ctrl_values { };
338+
339+ int nx { -3 };
340+
341+ bool result_is_ok { true };
342+
343+ const decimal_type my_tol { std::numeric_limits<decimal_type>::epsilon () * static_cast <decimal_type>(tol_factor) };
344+
345+ for (auto i = static_cast <std::size_t >(UINT8_C (0 )); i < std::tuple_size<str_ctrl_array_type>::value; ++i)
346+ {
347+ const decimal_type x_arg { 456 , nx };
348+
349+ ++nx;
350+
351+ log_values[i] = log10 (x_arg);
352+
353+ static_cast <void >
354+ (
355+ from_chars (ctrl_strings[i], ctrl_strings[i] + std::strlen (ctrl_strings[i]), ctrl_values[i])
356+ );
357+
358+ const auto result_log_is_ok = is_close_fraction (log_values[i], ctrl_values[i], my_tol);
359+
360+ result_is_ok = (result_log_is_ok && result_is_ok);
361+ }
362+
363+ return result_is_ok;
364+ }
365+
297366} // namespace local
298367
299368auto main () -> int
@@ -304,7 +373,18 @@ auto main() -> int
304373 using decimal_type = boost::decimal::decimal32;
305374 using float_type = float ;
306375
307- const auto test_log10_is_ok = local::test_log10<decimal_type, float_type>(128 );
376+ const auto test_log10_is_ok = local::test_log10<decimal_type, float_type>(64 );
377+
378+ BOOST_TEST (test_log10_is_ok);
379+
380+ result_is_ok = (test_log10_is_ok && result_is_ok);
381+ }
382+
383+ {
384+ using decimal_type = boost::decimal::decimal64;
385+ using float_type = double ;
386+
387+ const auto test_log10_is_ok = local::test_log10<decimal_type, float_type>(256 );
308388
309389 BOOST_TEST (test_log10_is_ok);
310390
@@ -333,6 +413,14 @@ auto main() -> int
333413 result_is_ok = (test_log10_edge_is_ok && result_is_ok);
334414 }
335415
416+ {
417+ const auto result_pos128_is_ok = local::test_log10_128 (1'400'000 );
418+
419+ BOOST_TEST (result_pos128_is_ok);
420+
421+ result_is_ok = (result_pos128_is_ok && result_is_ok);
422+ }
423+
336424 result_is_ok = ((boost::report_errors () == 0 ) && result_is_ok);
337425
338426 return (result_is_ok ? 0 : -1 );
0 commit comments