Fibonacci Coding

In mathematics, Fibonacci coding is a universal code which encodes positive integers into binary code words. All tokens end with "11" and have no "11" before the end. The code begins as follows:
  1  11  2  011  3  0011  4  1011  5  00011  6  10011  7  01011  8  000011  9  100011  10 010011  11 001011  12 101011 
The Fibonacci code is closely related to Fibonacci representation, a positional numeral system sometimes used by mathematicians. The Fibonacci code for a particular integer is exactly that of the integer's Fibonacci representation, except with the order of its digits reversed and an additional "1" appended to the end. To encode an integer X:
  1. Find the largest Fibonacci number equal to or less than X; subtract this number from X, keeping track of the remainder.
  2. If the number we subtracted was the Nth unique Fibonacci number, put a one in the Nth digit of our output.
  3. Repeat the previous steps, substituting our remainder for X, until we reach a remainder of 0.
  4. Place a one after the last naturally-occurring one in our output.
To decode a token in the code, remove the last "1", assign the remaining bits the values 1,2,3,5,8,13... (the Fibonacci numbers), and add the "1" bits.

See also

 

<< PreviousWord BrowserNext >>
218
216
urban growth boundary
215
989
988
987
985
982
981
valerie solanas
jean auguste dominique ingres
schema
anzac day
saul kripke
relativism
transcendental argument for the existence of god
syllogism
engrish
autonomous robot
david gauthier
moral relativism
argument from nonbelief
moral core
play school
19th century bc
sesame street
polder
snowdonia national park
maurice ravel
goldie hawn
journaling file system
essentialism
great circle
sesame workshop
virtual management
embarazado
list of welsh language poets
llywelyn the great
carnegie mellon university
intermezzo (file system)
bitch
visby
gdel, escher, bach