Faster Addition and Subtraction on Modern CPUs: Outsmarting Carry Propagation

2025-05-30

This article explores techniques to accelerate large integer addition and subtraction on modern CPUs. Traditional methods, similar to manual long addition, process digits from least to most significant, handling carries serially. This limits parallelism. The article proposes a clever approach: altering the number system to delay carry propagation, performing it all at once to exploit CPU parallelism, significantly boosting speed. The core idea involves splitting large integers into smaller parts, utilizing x86's `add` and `adc` instructions, and employing radix-251 representation to minimize carry operations, resulting in faster addition and subtraction than traditional methods.