Non-adjacent Form

The non-adjacent form (NAF) of a number is a unique signed-digit representation. Like the name suggests, adjacent values cannot be non-zero. For example:
(0 1 1 1) = 4 + 2 + 1 = 7
(1 0 −1 1) = 8 − 2 + 1 = 7
(1 −1 1 1) = 8 − 4 + 2 + 1 = 7
(1 0 0 −1) = 8 − 1 = 7
All are valid signed-digit representations of 7, but only the final representation (1 0 0 −1) is in NAF.

Obtaining NAF

There are several algorithms for obtaining the NAF representation of a value given in binary. One such is the modified Booth scheme:
Input: E = (em − 1 em − 2 ··· e1 e0)2
Output: E = (zm zm − 1 ··· z1 z0)NAF
em ← 0
e−1 ← 0
Find and replace all sequences of 0 1 ··· 1 0 (with k repeated 1's) with 1 0 ··· 0 −1 0 (with k − 1 repeated 0's)
i ← 0
while i < m do
if ei + 1 · ei ≠ 0 then
zi ← 2 · ei + 1 + ei
zi + 1 ← 0
ii + 2
else
ziei
ii + 1
return z
Another way, one that doesn't have to search for and count strings of 1's, is a method using repeated division:
Input: E = (0 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

Properties

NAF assures a unique representation of an integer, but the main benefit of it is that the Hamming weight of the value will be minimal. For regular binary representations of values, half of all bits will be non-zero, on average, but with NAF this drops to only one-third of all bits. Because every non-zero value has to be adjacent to two 0's, the NAF representation can be implemented such that it only takes a maximum of m + 1 bits for a value that would normally be represented in binary with m bits. The non-zero bits in NAF will toggle between 1 and −1 when examined from left-to-right or right-to-left — that is, if a bit of 1 is encountered, the next non-zero bits on the left and right will be −1 and vice versa. The properties of NAF make it useful in hardware implementations, especially those in cryptography.

 

<< PreviousWord BrowserNext >>
sadozai
epicure
saint duthus
shadowland (album)
cms 2
c cube
sinclair ross
the goodbye girl (album)
disney family
mopery
portmahomack
foal
cosey fanni tutti
statilia messalina
absolute torch and twang
signed digit representation
metro transit
the heart is deceitful above all things
citizen ruth
twisted tales of felix the cat
pierrette alarie
clive revill
adnan oktar
thomas pogge
dundee, nebraska
edward cross
craig krenzel
theon weber
grabsteins
projectai.com
ingenue (album)
cerebra
tom carvel
sabbath breaking
universit federico ii
parliamentary representation in montreal, 2004
mastoid process
arguments for and against drug prohibition
mark 117 bomb
daytona
puppethead players
dirty water
luft
all you can eat