Skip to content

Commit 72b1e56

Browse files
committed
Add power of 10 function
1 parent efc3b23 commit 72b1e56

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2025 Matt Borland
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// https://www.boost.org/LICENSE_1_0.txt
4+
5+
#ifndef BOOST_DECIMAL_DETAIL_IS_POWER_OF_10_HPP
6+
#define BOOST_DECIMAL_DETAIL_IS_POWER_OF_10_HPP
7+
8+
#include <boost/decimal/detail/config.hpp>
9+
#include <boost/decimal/detail/remove_trailing_zeros.hpp>
10+
#include <boost/decimal/detail/concepts.hpp>
11+
12+
namespace boost {
13+
namespace decimal {
14+
namespace detail {
15+
16+
template <typename T>
17+
constexpr auto is_power_of_10(const T x) noexcept
18+
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_unsigned_v, T, bool)
19+
{
20+
const auto removed_zeros {detail::remove_trailing_zeros(x)};
21+
return removed_zeros.trimmed_number == 1U;
22+
}
23+
24+
} // namespace detail
25+
} // namespace decimal
26+
} // namespace boost
27+
28+
#endif // BOOST_DECIMAL_DETAIL_IS_POWER_OF_10_HPP

0 commit comments

Comments
 (0)