To code a number X ≥ 1:
An equivalent way to express the same process:
To represent a number x {\displaystyle x} , Elias delta (δ) uses ⌊ log 2 ( x ) ⌋ + 2 ⌊ log 2 ( ⌊ log 2 ( x ) ⌋ + 1 ) ⌋ + 1 {\displaystyle \lfloor \log _{2}(x)\rfloor +2\lfloor \log _{2}(\lfloor \log _{2}(x)\rfloor +1)\rfloor +1} bits.2: 200 This is useful for very large integers, where the overall encoded representation's bits end up being fewer [than what one might obtain using Elias gamma coding] due to the log 2 ( ⌊ log 2 ( x ) ⌋ + 1 ) {\displaystyle \log _{2}(\lfloor \log _{2}(x)\rfloor +1)} portion of the previous expression.
The code begins, using γ ′ {\displaystyle \gamma '} instead of γ {\displaystyle \gamma } :
To decode an Elias delta-coded integer:
Example:
This code can be generalized to zero or negative integers in the same ways described in Elias gamma coding.
See also: Variable-length quantity § Zigzag encoding
Elias delta coding does not code zero or negative integers. One way to code all non negative integers is to add 1 before coding and then subtract 1 after decoding. One way to code all integers is to set up a bijection, mapping integers all integers (0, 1, −1, 2, −2, 3, −3, ...) to strictly positive integers (1, 2, 3, 4, 5, 6, 7, ...) before coding. This bijection can be performed using the "ZigZag" encoding from Protocol Buffers (not to be confused with Zigzag code, nor the JPEG Zig-zag entropy coding).
Elias, Peter (March 1975). "Universal codeword sets and representations of the integers". IEEE Transactions on Information Theory. 21 (2): 194–203. doi:10.1109/tit.1975.1055349. /wiki/Peter_Elias ↩