I\'m trying to take 21 bytes of data which uniquely identifies a trade and store it in a 16 byte char
array. I\'m having trouble coming up with the right algor
That makes (18*7+10)=136 bits, or 17 bytes. You wrote trade_num
is alphanumeric? If that means the usual [a-zA-Z0-9_] set of characters, then you'd have only 6 bits per character, needing (18*6+10)=118 bit = 15 bytes for the whole thing.
Assuming 8 bit = 1 byte
Or, coming from another direction: You have 128 bits for storage, you need ~10 bits for the number part, so there are 118 left for the trade_num. 18 characters means 118/18=6.555 bits per characters, this means you can have only the space to encode 26.555 = 94 different characters **unless there is a hidden structure in trade_num that we could exploit to save more bits.