应用密码学手册《Handbook of Applied Cryptography》的第14章给出大整数运算的常用算法,包括大整数加法运算。
其中大整数加法运算,可以假定两个大整数x、y均是非负整数,这种情形下的算法见《应用密码学手册》的14.7节,摘录如下:
14.7 Algorithm Multiple-precision addition
INPUT: positive integers x =(x~n~,x~n-1~,x~1~,x~0~)and y=(y~n~,y~n-1~,...y~1~,y~0~), each having n + 1 base b digits.
OUTPUT: the sum x + y = (w~n+1~,w~n~,· · ·, w~1~,w~0~)b in radix b representation.
1. c←0 (c is the carry digit).
2. For i from 0 to n do the following:
2.1 w~i~←(x~i~+ y~i~+ c) mod b
2.2 If (x~i~+ y~i~+ c) < b then c←0; otherwise c←1
3. w~n+1~←c
4. Return((w~n+1~,w~n~,· · ·, w~1~,w~0~)).
同时,文中指出若采用整数补表示(complement representation),则可以不用区分整数x、y的正负情形。.