Sprint 2015 | Program
In this assignment we were given an input file that had any number of 15 possible characters [0 1 2 3 4 5 6 7 8 9 period (.) dash (-) comma(,) single-space ( ) newline (\n)] and we had to compress the file into half the size, and then be able to decompress the file back to the original input file.
To do this, each character was converted from its ascii value to a value from 0-15 (4 bits). Then, this 4 bit representation of a symbol was stored in the first 4 bits of an 8 bit character, then the next 4 bit representation of the next symbol in the input was stored in the second 4 bits of the same 8 bit character. This 8 bit character was then saved into the output file. Because we were able to store two characters in the same memory of one character, the size became half.
To convert from the compressed format to the uncompressed format, each character in the compressed file was broken into the first 4 bits and the second 4 bits. We then convert the first 4 bits into the normal character representation (do the opposite of the compression) and save that character. Next, we would do the same for the last 4 bits of the compressed character.
For this assignment, there was no provided code.