Chapter 4

Basic Arithmetic

4.1 Introduction

At this point, algorithms for initialization, clearing, zeroing, copying, comparing, and setting small constants have been established. The next logical set of algorithms to develop are addition, subtraction, and digit shifting algorithms. These algorithms make use of the lower level algorithms and are the crucial building block for the multiplication algorithms. It is very important that these algorithms are highly optimized. On their own they are simple O(n) algorithms but they can be called from higher level algorithms, which easily places them at O(n2) or even O(n3) work levels.

All of the algorithms within this chapter make use of the logical bit shift operations denoted by and for left and right ...

Get BigNum Math now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.