Hi,
I'm trying to find a way to compress four 2-bit values into one byte. I have a file with four different 1 byte ascii characters, but since the "alphabet" has only 4 letters I can in theory code four of these into one byte.
I've made a method that takes four characters at the time, and "codes" them into one integer between 0 and 255. Since 1 byte can represent 256 different values, and one C char is one byte, I was under the impression that I could convert the 2-byte integer to a 1-byte char somehow, but I can't find out how to do this!? Is this possible, and if so - how??
Any suggestions would be greatly appreciated!
I'm trying to find a way to compress four 2-bit values into one byte. I have a file with four different 1 byte ascii characters, but since the "alphabet" has only 4 letters I can in theory code four of these into one byte.
I've made a method that takes four characters at the time, and "codes" them into one integer between 0 and 255. Since 1 byte can represent 256 different values, and one C char is one byte, I was under the impression that I could convert the 2-byte integer to a 1-byte char somehow, but I can't find out how to do this!? Is this possible, and if so - how??
Any suggestions would be greatly appreciated!