1- // Copyright 2024 Matt Borland
2- // Copyright 2024 Christopher Kormanyos
1+ // Copyright 2024 - 2026 Matt Borland
2+ // Copyright 2024 - 2026 Christopher Kormanyos
33// Distributed under the Boost Software License, Version 1.0.
44// https://www.boost.org/LICENSE_1_0.txt
55
@@ -50,22 +50,12 @@ namespace local
5050 {
5151 using std::fabs;
5252
53- auto result_is_ok = bool { };
54-
55- NumericType delta { };
56-
57- if (b == static_cast <NumericType>(0 ))
58- {
59- delta = fabs (a - b); // LCOV_EXCL_LINE
60-
61- result_is_ok = (delta < tol); // LCOV_EXCL_LINE
62- }
63- else
53+ const NumericType delta
6454 {
65- delta = fabs (1 - (a / b));
55+ (b == static_cast <NumericType>(0 )) ? fabs (a - b) : fabs (1 - (a / b))
56+ };
6657
67- result_is_ok = (delta < tol);
68- }
58+ const bool result_is_ok { (delta < tol) };
6959
7060 // LCOV_EXCL_START
7161 if (!result_is_ok)
@@ -110,9 +100,9 @@ namespace local
110100 auto trials = static_cast <std::uint32_t >(UINT8_C (0 ));
111101
112102 #if !defined(BOOST_DECIMAL_REDUCE_TEST_DEPTH)
113- constexpr auto count = ( sizeof (decimal_type) == static_cast < std::size_t >( UINT8_C ( 4 ))) ? UINT32_C ( 0x400 ) : UINT32_C ( 0x40 ) ;
103+ constexpr std:: uint32_t count { (( std::numeric_limits<DecimalType>::digits10 < 10 ) ? UINT16_C ( 3200 ) : UINT16_C ( 1600 )) } ;
114104 #else
115- constexpr auto count = ( sizeof (decimal_type) == static_cast < std::size_t >( UINT8_C ( 4 ))) ? UINT32_C ( 0x40 ) : UINT32_C ( 0x4 ) ;
105+ constexpr std:: uint32_t count { (( std::numeric_limits<DecimalType>::digits10 < 10 ) ? UINT16_C ( 320 ) : UINT16_C ( 160 )) } ;
116106 #endif
117107
118108 for ( ; trials < count; ++trials)
@@ -341,9 +331,9 @@ int main()
341331 using decimal_type = boost::decimal::decimal32_t ;
342332 using float_type = float ;
343333
344- const auto result_small_is_ok = local::test_cbrt<decimal_type, float_type>(INT32_C ( 16 ) , 1 .0E-26L , 1 .0E-01L );
345- const auto result_medium_is_ok = local::test_cbrt<decimal_type, float_type>(INT32_C ( 16 ) , 0 .9E-01L , 1 .1E+01L );
346- const auto result_large_is_ok = local::test_cbrt<decimal_type, float_type>(INT32_C ( 16 ) , 1 .0E+01L , 1 .0E+26L );
334+ const auto result_small_is_ok = local::test_cbrt<decimal_type, float_type>(16 , 1 .0E-26L , 1 .0E-01L );
335+ const auto result_medium_is_ok = local::test_cbrt<decimal_type, float_type>(16 , 0 .9E-02L , 1 .1E+01L );
336+ const auto result_large_is_ok = local::test_cbrt<decimal_type, float_type>(16 , 1 .0E+01L , 1 .0E+26L );
347337
348338 BOOST_TEST (result_small_is_ok);
349339 BOOST_TEST (result_medium_is_ok);
@@ -361,12 +351,12 @@ int main()
361351 }
362352
363353 {
364- using decimal_type = boost::decimal::decimal_fast32_t ;
365- using float_type = float ;
354+ using decimal_type = boost::decimal::decimal64_t ;
355+ using float_type = double ;
366356
367- const auto result_small_is_ok = local::test_cbrt<decimal_type, float_type>(INT32_C ( 16 ) , 1 .0E-26L , 1 .0E-01L );
368- const auto result_medium_is_ok = local::test_cbrt<decimal_type, float_type>(INT32_C ( 16 ) , 0 .9E-01L , 1 .1E+01L );
369- const auto result_large_is_ok = local::test_cbrt<decimal_type, float_type>(INT32_C ( 16 ) , 1 .0E+01L , 1 .0E+26L );
357+ const auto result_small_is_ok = local::test_cbrt<decimal_type, float_type>(16 , 1 .0E-26L , 1 .0E-01L );
358+ const auto result_medium_is_ok = local::test_cbrt<decimal_type, float_type>(16 , 0 .9E-01L , 1 .1E+01L );
359+ const auto result_large_is_ok = local::test_cbrt<decimal_type, float_type>(16 , 1 .0E+01L , 1 .0E+26L );
370360
371361 BOOST_TEST (result_small_is_ok);
372362 BOOST_TEST (result_medium_is_ok);
@@ -384,7 +374,7 @@ int main()
384374 }
385375
386376 {
387- using decimal_type = boost::decimal::decimal64_t ;
377+ using decimal_type = boost::decimal::decimal_fast64_t ;
388378 using float_type = double ;
389379
390380 const auto result_small_is_ok = local::test_cbrt<decimal_type, float_type>(INT32_C (16 ), 1 .0E-76L , 1 .0E-01L );
@@ -407,14 +397,14 @@ int main()
407397 }
408398
409399 {
410- const auto result_cbrt128_is_ok = local::test_cbrt_128 (96 );
400+ const auto result_cbrt128_is_ok = local::test_cbrt_128 (16 );
411401
412402 BOOST_TEST (result_cbrt128_is_ok);
413403
414404 result_is_ok = (result_cbrt128_is_ok && result_is_ok);
415405 }
416406
417- result_is_ok = (( boost::report_errors () == 0 ) && result_is_ok);
407+ BOOST_TEST ( result_is_ok);
418408
419- return (result_is_ok ? 0 : - 1 );
409+ return boost::report_errors ( );
420410}
0 commit comments