Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compression of numeric strings

Can anyone suggest compression algorithms to operate on numeric strings of 20-30 digits ?

like image 880
Vijay Dev Avatar asked Dec 02 '22 06:12

Vijay Dev


1 Answers

You can easily compress 30 character string down to 15 bytes by just using binary representations of each digit. For example, 1592 can be represented as a series of four-bit values as such:

0001 0101 1001 0010

This, when grouped in groups of two four-bit values, can be represented as §Т in standard ASCII.

Further, if your strings contain many identical consecutive digits, you can implement a variation of Run-Length Encoding.

like image 122
Anton Gogolev Avatar answered Dec 14 '22 22:12

Anton Gogolev