fractional binary subtraction

I am having difficulty understanding why the following binary subtraction gives the result that it does. I keep getting a different answer. I am trying to compute 0.1-x such that x is 0.00011001100110011001100. The answer should be 0.000000000000000000000001100[1100]...(1100 keeps repeating) When i do it, I keep getting 1100 in the very beginning.

What am I not doing correctly?

Answers


I think that your expected answer is wrong. Here's my solution. I'll group the bits into nybbles so that it would look readable.

  0.1000 0000 0000 0000 0000 0000 <- added zero to the rightmost to fill in the nybble
- 0.0001 1001 1001 1001 1001 1000 <- added zero to the rightmost to fill in the nybble
_________________________________

Get the 2's complement of 0.0001 1001 1001 1001 1001 1000.

  1.1110 0110 0110 0110 0110 0111 (1's complement)
+ 0.0000 0000 0000 0000 0000 0001
_________________________________
  1.1110 0110 0110 0110 0110 1000 (2's complement)

Add the 2's complement to 0.1.

  0.1000 0000 0000 0000 0000 0000
+ 1.1110 0110 0110 0110 0110 1000
_________________________________
 10.0110 0110 0110 0110 0110 1000

Since the overflow is 1, disregard it. It just signifies that the final answer is a positive number since 0.1 is larger than 0.0001 1001 1001 1001 1001 1000. Therefore, the final answer is 0.011001100110011001101000.


Need Your Help

how to hide button for specific user in opnerp

access-rights

I am creating access rights. I want to show one button for manager. don't show that button for user. how do i do it

Store a value in memory for an hour C#

c#

I need to store particular value in memory cache for one hour. After one hour automatically I will create another value and will assign in same memory.