Search for a tool
Elias Gamma Encoding

Tool to convert numbers according to the Elias Gamma code, denoted γ, encoding generally used in data compression to store data of arbitrary size.

Results

Elias Gamma Encoding -

Tag(s) : Compression, Notation System

Share
Share
dCode and more

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!


Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!


Feedback and suggestions are welcome so that dCode offers the best 'Elias Gamma Encoding' tool for free! Thank you!

Elias Gamma Encoding

Binary Gamma to Decimal Decoder


See also: Binary Code

Number to Elias' Gamma Encoder




See also: Binary Code

Answers to Questions (FAQ)

How to encode using Elias Gamma encoding?

Elias's gamma encoding is a universal code with a prefix. The prefix indicates the length of the binary string that follows it. It is therefore possible to encode any binary integer number.

To code a decimal number $ N $, take its binary representation $ N_{(2)} $ and calculate $ L = \lfloor \log_2 N \rfloor $ which is equivalent to its number of bits minus 1.

Example: To encode $ N = 5 $ which has for binary representation $ N_{(2)} = 101 $ (3 bits), calculate the integer part of $ \log_2 5 \approx 2.32 $ i.e. $ L = 2 $ (i.e. 1 less than the number of bits).

Encode in unary $ L $ and concatenate the binary representation without the most significant bit (the first 1) to obtain the Elias Gamma code $ \gamma $ that corresponds to $ N $

Example: $ L = 2 $ is coded in unary $ 001 $ (or sometimes $ 110 $) and the binary without the first $ 1 $ is $ 01 $ so the Elias encoding $ \gamma = 00101 $

Example: The first integers encoded with Gamma are&:

112010
3011400100
500101600110
70011180001000
90001001100001010
110001011120001100
130001101140001110
15000111116000010000
1700001000118000010010
1900001001120000010100

How to decode Elias Gamma encoding?

Read the binary value in order to split it into 2 sub-values of the same length separated by a bit: the first is the unary value corresponding to the number of bits minus 1, the second is the binary representation without the most significant bit.

To find the initial value, put a 1 in front of the second value and convert the binary number obtained to base 10.

Example: 00101 splits 00/1/01, the binary value is $ 101 $ which corresponds to the number $ 5 $.

How to recognize a Gamma encoding?

Binary numbers have always an odd-length.

Coded values always start with a long string of 0 (or 1)

Elias Gamma encoding is generally linked to data compression algorithms.

What are the variants of the Gamma encoding?

The unary code can be coded with 0 followed by a separator 1 or else with 1 followed by the separator 0.

Example: 5 can be coded as 000001 or 111110.

When Gamma coding was invented?

Peter Elias described it in an article titled Universal codeword sets and representations of the integers in 1975.

Source code

dCode retains ownership of the "Elias Gamma Encoding" source code. Except explicit open source licence (indicated Creative Commons / free), the "Elias Gamma Encoding" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "Elias Gamma Encoding" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Elias Gamma Encoding" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.

Cita dCode

The copy-paste of the page "Elias Gamma Encoding" or any of its results, is allowed (even for commercial purposes) as long as you cite dCode!
Exporting results as a .csv or .txt file is free by clicking on the export icon
Cite as source (bibliography):
Elias Gamma Encoding on dCode.fr [online website], retrieved on 2024-05-07, https://www.dcode.fr/elias-gamma-encoding

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Questions / Comments

Feedback and suggestions are welcome so that dCode offers the best 'Elias Gamma Encoding' tool for free! Thank you!


https://www.dcode.fr/elias-gamma-encoding
© 2024 dCode — El 'kit de herramientas' definitivo para resolver todos los juegos/acertijos/geocaching/CTF.
 
Feedback