[0] https://github.com/invertedtomato/integer-compression
[1] https://raw.githubusercontent.com/invertedtomato/integer-com...
Still trying to explore though.
[0] https://en.wikipedia.org/wiki/Dynamic_Markov_compression
Here's how LZMA does it, for instance: https://en.wikipedia.org/wiki/Lempel–Ziv–Markov_chain_algori...
These days, they would usually be combined with an arithmetic or range coder to store each binary digit more efficiently than just writing it directly to the file.