C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Single and multiple precision types

From: Jan Schultke <janschultke_at_[hidden]>
Date: Thu, 27 Nov 2025 05:15:22 +0100
Rather than introducing a whole set of new types, you could also provide a
single constant such as std::native_width. Then:

using Single = _BitInt(std::native_width);
using Mult2 = _BitInt(std::native_width * 2);

You could also just take the width of std::size_t, which is usually the
native width anyway, without adding any new features.

Keep in mind that it's extremely undesirable to have multiple types with
the same semantics but which are distinct and have different spellings. We
wouldn't want distinct template instantiations for _BitInt(64) and long long,
but that's unavoidable. At least we can avoid making the problem any worse
by not adding 3-4 differently flavored ways of spelling 128-bit integers.
We already have __int128 and may soon have _BitInt(128), so let's not also
add _Mult2 and long long long and whatever else.

On Thu, 27 Nov 2025 at 00:14, Lev Minkovsky via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Hello all,
>
>
>
> Thank you for your active participation in the discussion
> about extended precision types.
>
>
>
> There is a better way to accomplish what I am looking
> for. Virtually every hardware architecture provides some support for double
> precision math. For example, 32-bit platforms can effectively and directly
> do 64-bit operations, and 64-bit platforms – 128-bit operations. A good
> deal of that support is already available in existing C++ implementations.
>
> We now have the following set of integral types:
>
>
> 1. size-constrained fundamental types (e.g., long long is at least 64
> bit).
> 2. fixed-size library types, aliasing to fundamental types (e.g.,
> int16_t)
> 3. the potential future wide gamut of bit-precise types (e.g.,
> _BitInt(48)).
>
>
>
> In addition to those, we can introduce the following word-length-dependent
> types:
>
> _Single. unsigned _Single
> _Mult2, unsigned _Mult2.
>
> The _Single types will be aliases of some C++26 fundamental types. For
> example, on x64, _Single can be aliased to long long. The _Mult2 types on
> 32-bit platforms can aliased to (unsigned) long long, and on 64-bit
> platforms introduce standard 128-bit integer types.
>
>
>
> If we want to, we can also have the respective literals. For example,
>
> auto x = 1sl;
> auto y = 1m2;
>
>
> Here, x will be a single precision integer, and y – double precision
> integer, both equal to 1.
>
>
>
> All this should be easy to implement with native-level performance, and
> therefore we should expect quick and wide adoption.
>
> Please let me know if you think this is proposal worthy.
>
>
>
> Best regards –
>
>
>
> Lev Minkovsky
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2025-11-27 04:15:40