C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Modular integers

From: Hans Åberg <haberg_1_at_[hidden]>
Date: Tue, 13 Jan 2026 15:36:37 +0100
It is probably too complicated to do by hand. By contrast, recursive templates can halve the words until there is hardware support, the latter of which can be implemented by specializing an inline function.

> On 13 Jan 2026, at 14:42, Sebastian Wittmeier via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> Is this a Quality of Implementation issue or something for the standard?
> The implementations are meant to provide faster operations for certain sizes like certain powers of 2.
> -----Ursprüngliche Nachricht-----
> Von: Hans Åberg via Std-Proposals <std-proposals_at_[hidden]>
> Gesendet: Di 13.01.2026 14:44
> Betreff: Re: [std-proposals] Modular integers
> An: David Brown <david.brown_at_[hidden]>;
> CC: Hans Åberg <haberg_1_at_[hidden]>; std-proposals_at_[hidden];
>
> > On 13 Jan 2026, at 14:41, David Brown <david.brown_at_[hidden]> wrote:
> >
> > On 13/01/2026 14:34, Hans Åberg via Std-Proposals wrote:
> >> There might be support for modular integers int_mod<m> ≔ ℤ/mℤ for a modulus m that fits into a fixed-sized word, say 4096 bits for use in cryptology, m ≤ 2⁴⁰⁹⁶. With recursive templates, like those I have written, for fixed-size unsigned integral types up to uint4096_t, it should not be difficult to implement.
> >
> > "unsigned _BitInt(4096)" will give you that. That is already part of C23, and I believe it is coming to C++, though I don't know the current status off-hand.
>
> It is too slow.
>

Received on 2026-01-13 14:36:53