WITTEN, Ian H., NEAL, Radford M., CLEARY, John G. Arithmetic coding for data compression. Communications of the ACM, 1987, 30.6: 520-540. The code is written in C++ . It compiles fine with gcc.