Binary subtraction
Subtract the bottom number by adding its two's complement. Press Make negative to write the bottom number as a negative, then add. Click the bits, or type 0 and 1. You can use the carry boxes for your working.
Score 0 / 0
Streak 0
Best 0
Show the working
Press Enter for the next sum
How to subtract in binary
Computers subtract by adding a negative number. To work out A − B, add A and the two's complement of B.
- Make B negative: flip every bit (0 becomes 1, 1 becomes 0), then add 1. For example, Binary
0000 0101(Denary 5) flips to1111 1010, and adding 1 gives1111 1011(Denary −5). - Add: add A and the negative B, right to left, carrying as you go.
- Ignore the final carry: any carry out of the leftmost column is thrown away. The answer is the same number of bits as A and B.
Negative answers: in two's complement the leftmost bit is worth a negative amount (−128 for a byte, −8 for a nibble). If the answer starts with a 1, it is negative. For example, Binary 1111 1101 is −128 + 64 + 32 + 16 + 8 + 4 + 1 = Denary −3.