carry
.carry
is not zero:
a. Calculate answer
as the XOR of a
and b
to add without carrying.
b. Calculate carry
as the AND of a
and b
, then left shift by 1 to determine the carry.
c. Update a
to be answer
(the partial sum without carry).
d. Update b
to be carry
(the carry that needs to be added).a
as the final sum.