One of the most common ways to compress numbers (assuming you have more than one that you want to compress - it's hard to compress) uses delta coding . It works on the principle: if you know that the first number is x, and the numbers after it are relatively similar, you can encode subsequent numbers as (x + c1), (x + c2), etc.
In this scheme, you only need to encode the full x value once, and if your c values โโare less than your x, you can save a lot of space. You can also use a version of this that sorts the numbers first, and then your delta is among the last seen instead of a single number. With this method, you can make better use of a wider range of numbers.
source share