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:

    Continual success in obtaining those things which a man from time to time desireth, that is to say, continual prospering, is that men call FELICITY; I mean Felicity of this life. For there is no such thing as perpetual Tranquillity of mind, while we live here; because Life it self is but Motion, and can never be without Desire, nor without Faeroe, no more than without Sense.
    Thomas Hobbes (1579–1688)