I have been through different posts here in Stack Overflow relating my question, but none seem to answer it because in their questions, either the decimal representation is given (mine isn't) or the answer is vague to me (like this).
I'm trying to do subtraction of binary digits in fractions or in floating-point.
0.0110
- 0.100101
The answer given is -0.001101
, but the solution is not shown. Since I haven't seen any direct way (not DEC to BIN) to convert a binary fractional digit to its 2's complement, I tried implementing the solution from this lecture on 2's complement of binary fractions wherein you get the bit by bit complement and add the floating-point part (the background principle of adding the fractional part wasn't explained). Using that, my answer did not match the one indicated.
1.011010 <- 1's complement of 0.100101
+ 0.011010
__________
1.110100 <- 2's complement of 0.100101
The 2's complement is then added to 0.0110
:
0.011000
+ 1.110100
__________
10.001100 <- discard overflow '1'
I ended up with the erroneous answer of 0.0011
. What did I do wrong? Did I forget any principle that I could have used?