Non-adjacent Form - Obtaining NAF

Obtaining NAF

There are several algorithms for obtaining the NAF representation of a value given in binary. One such is the following method using repeated division; it works by choosing non-zero coefficients such that the resulting quotient is divisible by 2 and hence the next coefficient a zero.

Input: E = (em − 1 em − 2 ··· e1 e0)2
Output: E = (zm zm − 1 ··· z1 z0)NAF
i ← 0
while E > 0 do
if E is odd then
zi ← 2 − (E mod 4)
else
zi ← 0
E ← (Ezi)/2
ii + 1
return z

Read more about this topic:  Non-adjacent Form

Famous quotes containing the word obtaining:

    And if the civilized man’s pursuits are no worthier than the savage’s, if he is employed the greater part of his life in obtaining gross necessaries and comforts merely, why should he have a better dwelling than the former?
    Henry David Thoreau (1817–1862)