C++ Logo


Advanced search

Re: [std-proposals] 128-bit integers

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sun, 11 Feb 2024 09:24:22 -0800
On Sunday, 11 February 2024 05:51:20 PST Jan Schultke via Std-Proposals wrote:
> > But that is a separate discussion from, should std::int128_t be mandatory
> > in the first place?
> Yes. Multiple compilers provide 128-bit support already

Please note you forgot an important qualification:

Multiple compilers provide 128-bit support already *on 64-bit platforms*.
Those same compilers do not provide 128-bit support on 32-bit targets.

This exists because those compilers effectively use the same code to support a
double-word integer on both and to emulate certain operations that the
hardware may not provide directly, such as a full double-word-on-double-word

Supporting 128-bit on 32-bit systems would be doubling that again: quad-word
math. Additions and subtractions are trivially extensible, though they'll take
twice the time to run. Multiplications and divisions wouldn't be.

See LLVM's implementation of the full 128-bit division (for 64-bit machines):

Note: "double-word" and "quad-word" used here in their original sense, not
what the x86 assembly calls them, because those are stuck calling "word" the
16-bit quantity.

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2024-02-11 17:24:24