Article snapshot taken from Wikipedia with creative commons attribution-sharealike license.
Give it a read and then ask your questions in the chat.
We can research this topic together.
In mathematics, negafibonacci coding is a universal code which encodes nonzero integers into binary code words. It is similar to Fibonacci coding, except that it allows both positive and negative integers to be represented. All codes end with "11" and have no "11" before the end.
Encoding method
The following steps describe how to encode a nonzero integer . Note that denotes the Negafibonacci sequence.
If is positive, compute the greatest odd negative integer such that the sum of the odd negative terms of the Negafibonacci sequence from -1 to with a step of -2, is greater than or equal to :
If is negative, compute the greatest even negative integer such that the sum of the even negative terms of the Negafibonacci sequence from 0 to with a step of -2, is less than or equal to :
Add a 1 at the bit of the binary word. Subtract from .
Repeat the process from step 1 with the new value of x, until it reaches 0.
Add a 1 on the left of the resulting binary word to finish the encoding.
To decode an encoded binary word, remove the leftmost 1 from the binary word, since it is used only to denote the end of the encoded number. Then assign the remaining bits the values of the Negafibonacci sequence from -1 (1, −1, 2, −3, 5, −8, 13...), and sum the all the values associated with a 1.
Negafibonacci coding is closely related to negafibonacci representation, a positional numeral system sometimes used by mathematicians. The negafibonacci code for a particular nonzero integer is exactly that of the integer's negafibonacci representation, except with the order of its digits reversed and an additional "1" appended to the end. The negafibonacci code for all negative numbers has an odd number of digits, while those of all positive numbers have an even number of digits.
Table
The code for the integers from −11 to 11 is given below.