Sorry to say this, but it's always common knowledge to pad color values with less than eight bits. Color values are rarely converted with just five bits, they are always complemented with either zeroes, or a repetition of the bit string.
If a red value is 10110, then you won't output 22, since that would be a rather dark red. Instead, you pad it at the end, making it 10110000 (which is 176), or repeating the bit value until it makes up the eight bits, like 10110101 (which is 181, consisting of the original bit value, 10110, and the last three bits from the right, 10110).
This is common knowledge. Color values always go from 0% to 100%. In fact, if you really want, you could just calculate the color value by taking the current color value (10110 or 22), dividing it by the maximum color value (11111 or 31), so you would get the ratio (22 / 31 = 0.71), then multiplying it by 255 (which is 181).