C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Multiprecision division

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Thu, 7 Aug 2025 15:44:06 +0200
On 07.08.25 14:44, Hans Ã…berg via Std-Proposals wrote:
> I made a low-level multiprecision division function, similar in intent to the proposal https://isocpp.org/files/papers/P3161R4.html:
>
> For an unsigned type Word, dividend a[] of size n, divisor b[] of size b, the quotient is written into q[] and the remainder into a[]:
> template<class Word>
> inline void div(Word a[], size_t m, const Word b[], size_t n, Word q[])

We have three array parameters (decaying to pointers), but only two size parameters.
That feels odd to me. Also, "divisor b[] of size b," doesn't help my confusion.

Since this is supposed to be a C++ proposal, please make an interface based
on std::span, which doesn't have those issues.

What do you mean by "unsigned type Word"? Just built-in unsigned integer
types? If so, it's entirely in the realm of the implementation to
"make it work" for any unsigned integer type, so this is unnecessary:

> Then I have made a series of templates that choose the implementation: double-word if available, otherwise a half-word (which can be overridden by assembler specializations).

Jens

Received on 2025-08-07 13:44:14