Been learning about arithmetic coding and made this notebook to make it easier for people to understand.
It does have JavaScript's rounding issues, but the example is only 5 bytes so it doesn't break on that small data sample.
Looking at using big.js to see if that will fix the problem or use scaling so all the math can be done with integers.
https://observablehq.com/@hellonearthis/arithmetic-coding