xieite::digits()

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

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


Declaration

template<std::integral Int>
[[nodiscard]] constexpr std::size_t digits(Int x, Int radix = 10) noexcept;


Example

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