A simple compression algorithm that uses binary counting and concatenation to compress two small values (0 - 15) into a one-byte integer.

The C# class is not dependent on Unity to work. 

Compressing numbers like this could have utility in keeping saved data or memory usage small. Say you have a tile grid in a game that needs to be generated off of an enum. if this enum has 16 values or less, then you can compress each two tiles into one byte instead of using a byte integer for each individual tile, roughly doubling memory efficiency. 

StatusReleased
CategoryTool
PlatformsHTML5
Rating
Rated 5.0 out of 5 stars
(1 total ratings)
AuthorVivianPolygon
Made withUnity

Download

Download
BytePairCompressor.cs 5.7 kB

Comments

Log in with itch.io to leave a comment.

Thank you for this project. This is really something I was looking for (and to understand). You helped me tremendous with your little project/example.