ELI5: Explain Like I'm 5

Elias gamma coding

Elias gamma coding is like a special way of writing numbers so that they take up less space. It's like a secret code that only some people know how to read!

First, let's imagine we have a number we want to write down. Maybe it's 7.

With regular writing, we would just write "7," which takes up two spaces. But with Elias gamma coding, we can write it as "00111." That looks strange, but it's actually a shorter way of writing "7."

The code works by breaking the number down into two parts: a count of the number of digits in the number (in binary), and then the number itself (also in binary).

For 7, we know that it has three digits (1 1 1), because it's between 4 and 8. So we write down the binary code for the number 3 (which is "011"), and then add the digits of our number (which is "111"). So the whole code becomes "00111."

This method is really useful when we're dealing with big numbers. Instead of writing out a long string of numbers, we can just use Elias gamma coding to save space. And even though it looks complicated, it's still simple to use once you understand how it works.
Related topics others have asked about: