std::numeric_limits
provides 2 constants that are mutually exclusive:
is_integer
: "true
for all integer arithmetic types T
"
is_exact
: "true
for all arithmetic types T
that use exact representation"
Is there the possibility of a non-exact integral type? What is trying to be allowed for here?
In all my templates where I to know if I am dealing with precise numbers, I used is_integer
, do I need to go add a check for is_exact
as well now?
From is_exact
cppreference page:
Notes
While all fundamental types T for which
std::numeric_limits<T>::is_exact==true
are integer types, a library may define exact types that aren't integers, e.g. a rational arithmetics type representing fractions.
And, as @Holt has mentioned, the standard describes it as well:
21.3.4.1 numeric_limits members [numeric.limits.members]
static constexpr bool is_exact;
true if the type uses an exact representation. All integer types are exact, but not all exact types are integer. For example, rational and fixed-exponent representations are exact but not integer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With