xieite::num_digits()

Defined in fragment xieite:num_digits
(header-only: <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 value, T radix = 10) noexcept;
%%NOTES%%


Example

import xieite;

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