xieite::num_digits()

Defined in header <xieite/math/num_digits.hpp>

Computes the number of digits in a number, in any integral radix.


Declaration

template<std::integral T>
[[nodiscard]] constexpr std::size_t num_digits(T n, T radix = 10) noexcept;


Example

int main() {
	xieite::dump(xieite::num_digits(12345));
	xieite::dump(xieite::num_digits(255, 16)); // FF
	xieite::dump(xieite::num_digits(341, 2)); // 101010101
}
Output:
5
2
9
[View in Compiler Explorer]