Date: Thu, 07 Aug 2025 10:53:01 -0700
> On Aug 7, 2025, at 5:44 AM, Hans Åberg via Std-Proposals <std-proposals_at_[hidden]> 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[])
> By this structure, there is no need for internal allocations, which is important for speed. The “const” part is done via virtual shifts, which can be avoided by passing a b[] with the high bit set.
Rather than Word a[] these would really need to be at least std::span<Word> - we can harden span, but not raw pointers.
A lot of APIs seem to be written generically over iterators, but I find those APIs obnoxiously verbose - but also in practice I doubt anyone plans to make a multi precision library using std::set<word>s :D
—Oliver
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
> 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[])
> By this structure, there is no need for internal allocations, which is important for speed. The “const” part is done via virtual shifts, which can be avoided by passing a b[] with the high bit set.
Rather than Word a[] these would really need to be at least std::span<Word> - we can harden span, but not raw pointers.
A lot of APIs seem to be written generically over iterators, but I find those APIs obnoxiously verbose - but also in practice I doubt anyone plans to make a multi precision library using std::set<word>s :D
—Oliver
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2025-08-07 17:53:23