  the non-adjacent form (naf) of a number is a unique signed-digit representation. like the name suggests, non-zero values cannot be adjacent. for example: :(0 1 1 1)2 = 4 + 2 + 1 = 7 :(1 0 &minus;1 1)2 = 8 &minus; 2 + 1 = 7 :(1 &minus;1 1 1)2 = 8 &minus; 4 + 2 + 1 = 7 :(1 0 0 &minus;1)2 = 8 &minus; 1 = 7 all are valid signed-digit representations of 7, but only the final representation (1 0 0 &minus;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 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.d. hankerson, a. menezes, and s.a. vanstone, guide to elliptic curve cryptography, springer-verlag, 2004. p. 98. input e = (e'm &minus; 1 e'm &minus; 2 Â·Â·Â· e1 e0)2 output z = (z'm z'm &minus; 1 Â·Â·Â· z1 z0)naf i â 0 while e > 0 do if e is odd then z'i â 2 &minus; (e mod 4) else z'i â 0 e â (e &minus; z'i)/2 i â i + 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 digits. obviously, at most half of the digits are non-zero, which was the reason it was introduced by g.w. reitweisner in 1960 for speeding up early multiplication algorithms, much like booth encoding. because every non-zero digit 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 properties of naf make it useful in various algorithms, especially some in cryptography, e.g., for reducing the number of multiplications needed for performing an exponentiation. in the algorithm exponentiation by squaring the number of multiplications depends on the number of non-zero bits. if the exponent here is given in naf form a digit value 1 implies a multiplication by the base, and a digit value -1 by its reciprocal. other ways of encoding integers that avoid consecutive "1" digits include booth encoding, fibonacci coding, and pgp word list encoding. ==references== 
Non-standard_positional_numeral_systems