So I'm learning about binary values and I'm trying to understand how to calculate the negative version of a number using the fixed point bit model.
In my textbook it says 000111.01 = 7.25 which I understand. But it's telling me -7.25 is 111000.11 which I don't understand how that's possible.
I know it's using the two's complement rule where it flips all the bits and adds a 1 at the end. But if I did the calculation: (1 * 2^5) + ( 1 * 2^4) + (1 & 2^3) + 0 + 0 + 0 + (1 * 2^-1) + ( 1 * 2^-2) it gives me 56.75.
I tried looking up tutorials online but I still can't figure out why -7.25 is 111000.11. I would appreciate it if someone could explain the mathematical process behind getting -7.25.
You have an signed 8-bit 6Q2 format fixed point representation having a resolution of 2-2 (or 0.25). You can look at this purely arithmetically:
The int8_t
value of 11100011 is -29, but with the fixed point scaling that is -29 x 0.25 = -7.25.
Or then in terms of 2's compliment bit values which for an 8 bit integer are:
-27 (-12810)
26 (6410)
25 (3210)
24 (1610)
23 (810)
22 (410)
21 (210)
20 (110)
but the Q2 fixed point shifts those place values by 2 as follows:
-25 (-3210)
24 (1610)
23 (810)
22 (410)
21 (210)
20 (110)
2-1 (0.510)
2-2 (0.2510)