0
$\begingroup$

So I'm performing some operations with fractional numbers in a 16-bit FIXED-POINT processor.

I have to add the numbers $\ x=-7.1$, represented in $\ Q_{12}$, and $\ y=0.75$, represent in $\ Q_{15}$. So to perform this I know I first need to shift $\ y$ to $\ Q_{12}$, add up the numbers and shift again to $\ Q_{11}$.

First I represent the numbers in the respective notation in binary. The MSB is the sign bit.

So $\ x=1111.000110011010$ and $\ y=0.110000000000000$. Ok now I represent $\ y$ in $\ Q_{12}$, $\ y=0000.110000000000$. I know the binary point is just in our mind and the processor treats this numbers as integers.

Ok then we add up the numbers and get $\ x+y=1111.110110011010$. Finally convert this to $\ Q_{11}$, $\ x+y=11111.11011001101$. However if I performed the operation in decimal I would get $\ x+y=-6.35$, and representing it in $\ Q_{11}$, $\ x+y=10110.01011001101$. What is going on here? Why is the result different? Am I missing something?

$\endgroup$
1
  • 1
    $\begingroup$ Generally negative numbers are represented in two's complement which allows straightforward addition of the type you seem to expect. $\endgroup$ – Joffan Mar 26 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.