The radix 2^51 trick
Faster addition and subtraction on modern CPUs
Do you remember how to do long addition on paper?
¹¹ ¹
6876
+ 3406
------
10282
Starting from the “ones” position, we add 6 + 6 = 12, write down a 2 and carry a 1.
We proceed to the left, one position at a time, until there are no more digits
to add.
When implementing addition for large integers (e.g. 264 and above), it’s common to write
code that looks quite similar to this algorithm.
Interestingly, there’s a straightforward trick that can speed up...
Read more at chosenplaintext.ca