A method and system of lossless compression of integer data using a novel
backward-adaptive technique. The adaptive Run-Length and Golomb/Rice
(RLGR) encoder and decoder (codec) and method switches between a
Golomb/Rice (G/R) encoder mode only and using the G/R encoder combined
with a Run-Length encoder. The backward-adaptive technique includes novel
adaptation rules that adjust the encoder parameters after each encoded
symbol. An encoder mode parameter and a G/R parameter are adapted. The
encoding mode parameter controls whether the adaptive RLGR encoder and
method uses Run-Length encoding and, if so, it is used. The G/R parameter
is used in both modes to encode every input value (in the G/R only mode)
or to encode the number or value after an incomplete run of zeros (in the
RLGR mode). The adaptive RLGR codec and method also includes a decoder
that can be precisely implemented based on the inverse of the encoder
rules.