# Binary Data encoding and decoding format

I am trying to understand what is the meaning of this data coding format as shown in the following image. It is not simple binary to decimal conversion. Can anyone tell how this conversion formula works?

• From the first paragraph, it looks like you just have to flip the bits so a 0b00000001 becomes a 0b10000000. I am a bit confused by the second paragraph though, because 0x9B backwards should be 0xD9. 0b1001 1011 = 0x9B becomes 0b1101 1001 = 0xD9. I could very well be mistaken... Commented Mar 30, 2020 at 10:16

It's equivalent to a conventional binary representation except that the final value is scaled.

In the example they set the value of the LSB to 0.1, so the next bit has value 0.2, then next 0.4, 0.8, 1.6, 3.2, ... and so on. This is equivalent to decoding the binary as an unsigned integer in the usual way (bit values 1, 2, 4, 8, ...) and then multiplying the result by 0.1.

9B is 155 in decimal, so the intended value is 155 * 0.1 = 15.5.

• If I am given following info: LSB = 0.03125, MSB = 1024, Number of bits = 16, Minimum scaled value = 27, Maximum scaled value = 1090. Then how do I do the above conversion calculation? Commented Mar 30, 2020 at 13:00
• Decode the 16 bits as an unsigned binary number in the range 0-65535 and then multiply by 0.03125. Note that this will give a number in the range 0-2047.96875. The information you have about the minimum and maximum isn't consistent with the encoding and is just additional knowledge about what values you expect to see. Commented Mar 30, 2020 at 13:05
• OK. Is it some custom coding technique or is it used generally in data communication? I have not seen this type of data coding in any book so far. Commented Mar 30, 2020 at 13:54
• It is a generalisation of the "binary fixed point representation" (Google it), where the LSB would have a value that is a power of two (including negative powers such as 0.5, 0.25, 0.125, etc.). It's a bit funky to use a value that isn't a power of two for the LSB, such as 0.1. I've never seen that used before (been a developer for 20+ years). Feel free to accept my answer btw :) Commented Mar 30, 2020 at 20:58