std::numeri...ts::is_exact(3)
π std::numeric_limits::is_exact(3)
okay so picture this: we're deep in the C++ Standard Libary man pages (yes that's literally how it's spelled up top, don't come for me π) and we're here to talk about one tiny little static member that answers a very important question: "bestie, does your number type keep it π― exact?"
β¨ NAME β¨
std::numeric_limits::is_exact β literally just std::numeric_limits::is_exact, she's self-titled, main character energy π
π Synopsis π
static const bool is_exact; (until C++11)
static constexpr bool is_exact; (since C++11)
The way this works is so simple it's giving minimalist: the value of std::numeric_limits<T>::is_exact is true for all arithmetic types T that use exact representation. That's it. That's the whole vibe. β¨
πΈ Standard specializations πΈ
here's the full roll call, no skips, no cuts, everybody gets a line π
/* non-specialized */βfalseboolβtruecharβtruesigned charβtrueunsigned charβtruewchar_tβtruechar8_t(since C++20) βtruechar16_t(since C++11) βtruechar32_t(since C++11) βtrueshortβtrueunsigned shortβtrueintβtrueunsigned intβtruelongβtrueunsigned longβtruelong long(since C++11) βtrueunsigned long long(since C++11) βtruefloatβfalsedoubleβfalselong doubleβfalse
so the integers ate and left no crumbs, and the floating point girlies are sitting at false β that's the whole energy of this table π«Ά
π¦ Notes π¦
okay real talk, here's the little caveat that lives in the footnotes: while all fundamental types T for which std::numeric_limits<T>::is_exact == true are integer types, a library may define exact types that are not integers β for example, a rational arithmetic type representing fractions. so like, exact β automatically integer, iykyk π
π See also π
is_integerβ identifies integer types β [static] (public static member constant)is_signedβ identifies signed types β [static] (public static member constant)is_boundedβ identifies types that represent a finite set of values β [static] (public static member constant)
π friendly reminder: everything above is descriptive, so don't go assuming an exact type is an integer just because every fundamental one happens to be. read the Notes section, bestie, it's there for a reason.
and that's the page!! source is http://cppreference.com, dated 2024.06.10, filed under std::numeric_limits::is_exact(3) β go off and check your types, mwah π
πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms