Date: Thu, 7 Aug 2025 18:56:15 +0200
> On 7 Aug 2025, at 18:40, Howard Hinnant <howard.hinnant_at_[hidden]> wrote:
>
> Fwiw, here’s my attempt at multiprecision division:
>
> https://github.com/HowardHinnant/bbi
>
> https://github.com/HowardHinnant/bbi/blob/master/bbi.h#L2542-L2637
>
> I include it in this discussion just to widen the conversation, and perhaps give you something to show how much faster your algorithm is compared to this (I have no doubt it is). My implementation is limited to power-of-2 bit widths, and defines division of bit-width N in terms of operations on bit-width N/2. This recursivie formulation also avoids memory allocation.
I think it might be effective to make power 2 types recursively using “div”, or “div” in the proposal.
That could be motivation for adding uint128_t and for higher powers of 2 to the standard.
> I know practically nothing about this domain.
I also hope that the real experts will take over. :-)
> I got my algorithms from Hacker’s Delight:
>
> https://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/0321842685#:~:text=In%20Hacker's%20Delight%2C%20Second%20Edition,by%20the%20opportunity%20to%20improve.
I came across this example:
https://github.com/hcs0/Hackers-Delight/blob/master/divmnu64.c.txt
It does an internal allocation using “alloca”, which, though it is fast, sets a limitation on the size.
That was one motivation, to remove such internal allocations, for the form I presented here.
>
> Fwiw, here’s my attempt at multiprecision division:
>
> https://github.com/HowardHinnant/bbi
>
> https://github.com/HowardHinnant/bbi/blob/master/bbi.h#L2542-L2637
>
> I include it in this discussion just to widen the conversation, and perhaps give you something to show how much faster your algorithm is compared to this (I have no doubt it is). My implementation is limited to power-of-2 bit widths, and defines division of bit-width N in terms of operations on bit-width N/2. This recursivie formulation also avoids memory allocation.
I think it might be effective to make power 2 types recursively using “div”, or “div” in the proposal.
That could be motivation for adding uint128_t and for higher powers of 2 to the standard.
> I know practically nothing about this domain.
I also hope that the real experts will take over. :-)
> I got my algorithms from Hacker’s Delight:
>
> https://www.amazon.com/Hackers-Delight-2nd-Henry-Warren/dp/0321842685#:~:text=In%20Hacker's%20Delight%2C%20Second%20Edition,by%20the%20opportunity%20to%20improve.
I came across this example:
https://github.com/hcs0/Hackers-Delight/blob/master/divmnu64.c.txt
It does an internal allocation using “alloca”, which, though it is fast, sets a limitation on the size.
That was one motivation, to remove such internal allocations, for the form I presented here.
Received on 2025-08-07 16:56:31