File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -458,6 +458,21 @@ auto test_big_uints_shl() -> void
458458 }
459459}
460460
461+ template <typename T>
462+ void test_digit_counting ()
463+ {
464+ constexpr auto max_power {std::is_same<T, boost::decimal::detail::uint256_t >::value ? 77 : 38 };
465+
466+ T current_power {1 };
467+ int current_digits {1 };
468+ for (int i {}; i <= max_power; ++i)
469+ {
470+ BOOST_TEST_EQ (num_digits (current_power), current_digits);
471+ current_power = current_power * UINT64_C (10 );
472+ ++current_digits;
473+ }
474+ }
475+
461476int main ()
462477{
463478 test_big_uints_mul<boost::multiprecision::uint128_t , boost::decimal::detail::uint128 >();
@@ -475,6 +490,9 @@ int main()
475490 test_big_uints_shl<boost::multiprecision::uint128_t , boost::decimal::detail::uint128 >();
476491 test_big_uints_shl<boost::multiprecision::uint256_t , boost::decimal::detail::uint256_t >();
477492
493+ test_digit_counting<boost::decimal::detail::uint128>();
494+ test_digit_counting<boost::decimal::detail::uint256_t >();
495+
478496 return boost::report_errors ();
479497}
480498
You can’t perform that action at this time.
0 commit comments