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 ← (E − zi)/2
- i ← i + 1
- if E is odd then
- return z
Read more about this topic: Non-adjacent Form
Famous quotes containing the word obtaining:
“If, after obtaining Buddhahood, anyone in my land
gets tossed in jail on a vagrancy rap, may I
not attain highest perfect enlightenment.”
—Gary Snyder (b. 1930)