C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Modular integers

From: Hans Åberg <haberg_1_at_[hidden]>
Date: Wed, 14 Jan 2026 19:24:05 +0100
> On 14 Jan 2026, at 19:07, David Brown <david.brown_at_[hidden]> wrote:
>
>
> On 14/01/2026 18:31, Hans Åberg via Std-Proposals wrote:
>>>
>> Indeed, it is a C compatibility type, intended to work exactly in C,
>> which imposes some limitations. Discussions in the past focused on
>> making a separate C++ type for bit interesting, which I think would
>> be good.
>
> What limitations do you think are imposed by compatibility with C _BitInt ?
>
> There are plenty of things that will be nicer in C++ if these are also available as a C++ template - std::bitint<N>. But in what way do you think things would be limited if it is an identical type to C23's _BitInt(N), and that the two names can be used interchangeably in C++ ?

They discussed alignment here before. Also, padding to the nearest 2^(2^k) would be needed for the recursive templates.

I think the idea of this type is to implement it using a traditional 64-32-bit division algorithm, like some C multiprecision functions in GCC, though it might admit better implementations.

Received on 2026-01-14 18:24:24