I have been working on an assignment for university in which I have to compress an 80K message consisting of only two symbols, 'a' and 'b', having probability values of 0.6 and 0.4.

I have successfully written my code in Matlab and it is working efficiently for 10-20 symbols. However when I pass my 80k symbol message through my code it stops updating at the 1057th value due to the Range parameter, which achieves a value of 10^-324 (the theoretical limit of type double float).

My question is, is this the limitation of arithmetic coding when the range becomes so small that we cannot work with it or am doing something wrong?

I am working on arithmetic encoder, so no answers related to range decoding will work.

  • $\begingroup$ You could just just break the 80k messages down into 80 frames of 1k message each. $\endgroup$
    – Hilmar
    Dec 6, 2013 at 23:42
  • $\begingroup$ this will certainly give me 80 different codes, where one code in IEEE-64 bit standard will be of atleast 64 bit, and compression ration will be 64/1000 ............ Not enough :( $\endgroup$
    – Hafeez
    Dec 7, 2013 at 6:57

1 Answer 1


You should not be using floats or doubles to store your message. You need to write your compressed message in binary.

  • $\begingroup$ can you elaborate further? $\endgroup$
    – Hafeez
    Dec 7, 2013 at 6:58
  • $\begingroup$ You don't want to store your message in floating point format because these have fixed precision. That is the limitation that you alluded to in the title of your question. You should write out your compressed message as a binary stream. Assume that all of the digits in the stream occur after the decimal point. So 1 is 1/2 11 is 3/4 101 is 5/8 and so on. You can keep going on compressing your data forever like this $\endgroup$
    – Aaron
    Dec 7, 2013 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.