C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Integer overflow arithmetic

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Sun, 18 Feb 2024 13:46:45 -0500
On Sun, Feb 18, 2024 at 1:23 PM Tiago Freire via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> > Who cares about the specifics of how that operation is implemented. It
> is a good way to EXPRESS the operation in the C++ language, and in
> principle, the codegen can be optimal. If it isn't, that's a
> quality-of-implementation issue and not relevant to the C++ standard.
>
> Ok, here's a challenge. Try implementing the standard set of 512bit
> operations in terms of 128bit casts, and let's see how fun that is.
> Let's see if it is the "better" interface.
>

Aren't you just describing multiprecision integer math, as seen in e.g.
https://quuxplusone.github.io/blog/2020/02/13/wide-integer-proof-of-concept/
https://godbolt.org/z/5Mfqn7K8a
(note: four years ago, and I haven't revisited it in two years; I don't
know how Abseil, Boost.Multiprecision, or Clang's _BitInt stack up these
days)
? You don't need any particular core-language support for that — although
it doesn't hurt. You *certainly* don't need standard library support. There
are plenty of third-party libraries that implement wide math already.

–Arthur

Received on 2024-02-18 18:46:59