Negafibonacci
   HOME

TheInfoList



OR:

In
mathematics Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
, negafibonacci coding is a universal code which encodes nonzero integers into binary code words. It is similar to
Fibonacci coding In mathematics and computing, Fibonacci coding is a universal code which encodes positive integers into binary code words. It is one example of representations of integers based on Fibonacci numbers. Each code word ends with "11" and contains n ...
, 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 x . Note that f denotes the Negafibonacci sequence. # If x is positive, compute the greatest odd negative integer n such that the sum of the odd negative terms of the Negafibonacci sequence from -1 to n with a step of -2, is greater than or equal to x :
n \in \ , \quad \sum_^ f(i) < x \leq \sum_^ f(i).
If x is negative, compute the greatest even negative integer n such that the sum of the even negative terms of the Negafibonacci sequence from 0 to n with a step of -2, is less than or equal to x :
n \in \ , \quad \sum_^ f(i) > x \geq \sum_^ f(i) # Add a 1 at the , n, ^ bit of the binary word. Subtract f(n) from x . # 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 representation

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.


See also

*
Fibonacci numbers In mathematics, the Fibonacci sequence is a sequence in which each element is the sum of the two elements that precede it. Numbers that are part of the Fibonacci sequence are known as Fibonacci numbers, commonly denoted . Many writers begin the s ...
*
Golden ratio base Golden ratio base is a non-integer positional numeral system that uses the golden ratio (the irrational number \frac ≈ 1.61803399 symbolized by the Greek letter φ) as its base. It is sometimes referred to as base-φ, golden mean b ...
* Zeckendorf's theorem


References


Works cited

* * In th
pre-publication draft of section 7.1.3
see in particular pp. 36–39. * {{DEFAULTSORT:Negafibonacci Coding Non-standard positional numeral systems Lossless compression algorithms Fibonacci numbers Data compression fr:Codage de Fibonacci