C++ Logo

std-proposals

Advanced search

[std-proposals] Why is is_bounded != false required for digits10, but not for digits?

From: Ivan Matek <libbooze_at_[hidden]>
Date: Sat, 15 Feb 2025 05:28:31 +0100
Hi everybody,
I may be misunderstanding something so first brief recap, then my question.

Current https://eel.is/c++draft/numeric.limits and C++26 draft say this:

static constexpr bool is_bounded;
true if the set of values representable by the type is finite.
[Note 3: All fundamental types ([basic.fundamental]) are bounded. This
member would be false for arbitrary precision types. — end note]
Meaningful for all specializations.

Makes sense, it is important to know if type has infinite or finite number
of values it can represent(here we obviously ignore fact of finite memory,
etc).

But there is weird difference between digits and digits10 in terms of
requirements:

digits:
(no requirements)
digits10:
Meaningful for all specializations in which is_bounded != false.


I find this confusing. In my mind only difference between the two is
scaling factor and rounding. In other words:
T has supports for infinite digits ⇒ T has support for infinite digits10

so same requirement should apply for digits(i.e. that is_bounded != false).

If somebody is interested I checked what boost multiprecission reports and
seems a bit inconsistent between cpp_int and gmp_int.
https://godbolt.org/z/n19sYxvdq
but in any case it is not super important since this is question about the
standard.

Received on 2025-02-15 04:28:44