Date: Thu, 7 Aug 2025 16:04:23 +0200
> On 7 Aug 2025, at 15:44, Jens Maurer <Jens.Maurer_at_[hidden]> wrote:
>
> 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.
It is because it is low-level, avoiding unnecessary interface convenience. The idea is to build other interfaces on top of it. Specifically, the requirement for q can be computed from m and n.
> Also, "divisor b[] of size b," doesn't help my confusion.
Typo, it is correct in the function: divisor b[] of size n.
Division on signed integral types is typically implemented via the unsigned ones.
>
> 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.
It is because it is low-level, avoiding unnecessary interface convenience. The idea is to build other interfaces on top of it. Specifically, the requirement for q can be computed from m and n.
> Also, "divisor b[] of size b," doesn't help my confusion.
Typo, it is correct in the function: divisor b[] of size n.
Division on signed integral types is typically implemented via the unsigned ones.
Received on 2025-08-07 14:05:39