FACTOID # 97: Got a parking ticket in Finland? Better just pay up - it is the least corrupt nation in the world.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Fibonacci coding

The Fibonacci code 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 

Fibonacci Representation

To convert an integer x to its Fibonacci representation:

  1. Replace x with the difference between x and the largest Fibonacci number less than or equal to x and let the output be 1
  2. If the previous (next smaller) Fibonacci number is less than or equal to x, replace x with the difference, and append 1 to the output. Else, append 0 to the output. Repeat this step until the Fibonacci number 1 is encountered.

This method guarantees that there are no consecutive 1's in the Fibonacci representation of any number.


Encoding

To encode an integer x as little-endian:

  1. Convert x to its Fibonacci representation
  2. Change the representation to little endian and append a 1 after the last 1

Example: 46 -> 10010101 -> 10101001 -> 101010011



To encode an integer x as big-endian:

  1. Convert x to its Fibonacci representation
  2. Remove the leading 10 and appending a trailing 011

Example: 46 -> 10010101 -> 010101 -> 010101011


  Results from FactBites:
 
Fibonacci coding - Encyclopedia, History, Geography and Biography (381 words)
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.
Fibonacci coding has a useful property that sometimes makes it attractive in comparison to other universal codes: it is easier to recover data from a damaged stream.
With Fibonacci coding, on the other hand, a changed bit may cause one token to be read as two, or cause two tokens to be read incorrectly as one, but reading a "0" from the stream will stop the errors from propagating further.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.