I'm having trouble finding a solution for this. I need a method to store a string and a byte in a single int value. A hash is not good for this since the method should allow en- and decoding. Any hints would be appreciated, couldn't find a suitable algorithm.
Regards
Leo Tietz
An int
has 32 bits. The byte will take 8 bits. That leaves you 24 bits to play with - enough for one and a half char
values, uncompressed.
Unless you really only need to store single character strings, or you have a restricted range of characters that you need to represent, you need to revisit your requirements - it sounds like you're fundamentally going to have a problem with the amount of information you're trying to encode in a single int
.
See more on this question at Stackoverflow