## About the calculator

This calculator performs the subtraction for 2 binary numbers. You can select whether regrouping or the Austrian method should be used. The binary numbers may be negative, but must have the same sign.

## Subtracting binary numbers using regrouping

To illustrate how 2 binary numbers are subtracted with regrouping, the following subtraction should be performed:

10001010_{2} − 111000101_{2}

The two binary numbers are written one below the other in such a way that the larger number is at the top. If the two binary numbers have no fractional digits, they are written one below the other so that the last digits are one below the other. If the two binary numbers have fractional digits, they are written one below the other so that the binary points are underneath each other. Above the two numbers some space is left blank.

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

Then, starting from the right, try to subtract the digit of the bottom number from the digit of the top number for each column. If the difference between the digits is 0 or 1, then the difference is written into the solution.

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

1 |

If the difference is negative, the upper digit must be increased by 10_{2} (corresponds to 2 in the decimal system). To do this, you can cross out the 0 and write a 10 above it. The 10 is to be read as a binary number.

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

1 |

10 | |||||||||

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

1 |

To increase the upper digit in a column, 1 must be subtracted from the upper digit one column to the left. If the upper digit is 1, this is possible without any problems. The 1 is then crossed out and a 0 is written above it.

0 | 10 | ||||||||

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

1 |

The 10_{2} now replaces the 0 of the upper number. The subtraction can now be performed for this column.

0 | 10 | ||||||||

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

1 | 1 |

If the upper digit of the current column must be increased, but the upper digit one column to the left is 0, then this 0 must be increased by 10_{2} before 1 is subtracted from it. In this case, the upper digit must be reduced by 1 in the next column to the left. If this is not possible without creating a negative number, then it must also be increased by 10_{2} before it is reduced by 1, and one further column to the left, the upper digit must be reduced by 1. This is done until a 1 has been reached in the upper digit.

10 | 0 | 10 | |||||||

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

0 | 1 | 1 |

10 | 10 | 0 | 10 | ||||||

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

0 | 1 | 1 |

10 | 10 | 0 | 10 | ||||||

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

0 | 1 | 1 |

10 | 10 | 10 | 0 | 10 | |||||

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

0 | 1 | 1 |

10 | 10 | 10 | 0 | 10 | |||||

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

0 | 1 | 1 |

0 | 10 | 10 | 10 | 0 | 10 | ||||

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

0 | 1 | 1 |

0 | 10 | 10 | 10 | 0 | 10 | ||||

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

0 | 1 | 1 | 1 | 0 | 1 | 1 |

If a number has more digits before or after the binary point than the other, then there are columns in which there is no digit for either the upper or the lower number. Either you write a 0 in these places or you imagine that there would be a 0 in these places.

0 | 10 | 10 | 10 | 0 | 10 | ||||

1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | |

1 | 0 | 0 | 1 | 1 | 1 | 0 | 1 | 1 |

If the minuend and the subtrahend had to be swapped for the calculation (i.e. if the subtrahend was greater than the minuend), then the solution is negative.

_{2}is smaller than the subtrahend 111000101

_{2}. Therefore, the minuend and the subtrahend had to be swapped for the calculation. The solution of the subtraction is therefore negative.

_{2}− 111000101

_{2}= −100111011

_{2}

## Subtracting binary numbers using Austrian method

To illustrate how 2 binary numbers are subtracted using the Austrian method, the following subtraction should be performed:

101100_{2} − 10010101_{2}

To subtract one binary number from another using the Austrian method, the two numbers are first written one below the other. Make sure that the larger number is at the top. If the two binary numbers have no fractional digits, then they are written one below the other so that their last digits are underneath each other. If they both have fractional digits, then they are written so that the binary points of both binary numbers are underneath each other. One line is left blank below the two numbers.

1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 1 | 1 | 0 | 0 | ||

Then, starting from the right, try to subtract the digit of the bottom number from the digit of the top number for each column. If the difference is 0 or 1, it is written to the solution.

1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 1 | 1 | 0 | 0 | ||

0 | 0 | 1 |

If the difference is negative, the upper digit must be increased by 10_{2} (i.e. 2 in the decimal system). The 1 is written one column to the left below the two numbers.

1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 1 | 1 | 0 | 0 | ||

0 | 0 | 1 |

1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 1 | 1 | 0 | 0 | ||

1 | ||||||||

0 | 0 | 1 |

After the upper digit has been increased by 10_{2}, the subtraction can be performed.

1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 1 | 1 | 0 | 0 | ||

1 | ||||||||

1 | 0 | 0 | 1 |

If there is another 1 under the two digits in a column, it is mentally added to the digit of the lower number before it is subtracted from the digit of the upper number.

1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 1 | 1 | 0 | 0 | ||

1 | ||||||||

0 | 1 | 0 | 0 | 1 |

If a number has more digits before or after the binary point than the other, then there are columns in which there is no digit for either the upper or the lower number. Either you write a 0 in these places or you imagine a 0 in these places.

1 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | |

− | 1 | 0 | 1 | 1 | 0 | 0 | ||

1 | 1 | 1 | ||||||

0 | 1 | 1 | 0 | 1 | 0 | 0 | 1 |

If the minuend and the subtrahend had to be swapped for the calculation (i.e. if the subtrahend was greater than the minuend), then the solution is negative.

_{2}is smaller than the subtrahend 10010101

_{2}. Therefore, the minuend and the subtrahend had to be swapped for the calculation. The solution of the subtraction is therefore negative.

_{2}− 10010101

_{2}= −1101001

_{2}

## Subtraction with negative binary numbers

### both binary numbers are negative:

If both binary numbers of the subtraction are negative, first perform the subtraction with the absolute values of the numbers and then change the sign.

For example, the following subtraction is to be performed:

−1001_{2} − (−11_{2})

First, the subtraction is performed with absolute values:

0 | 10 | 10 | ||

1 | 0 | 0 | 1 | |

− | 1 | 1 | ||

0 | 1 | 1 | 0 |

Then the sign is changed:

−1001_{2} − (−11_{2}) | = | −(1001_{2} − 11_{2}) |

= | 110_{2} |

### subtrahend is negative:

If the minuend is positive and the subtrahend is negative, then the minuend must be added with the absolute value of the subtrahend.

For example, the following subtraction is to be performed:

1001_{2} − (−11_{2})

The calculation is made:

1 | 0 | 0 | 1 | |

+ | 1 | 1 | ||

1 | 1 | |||

1 | 1 | 0 | 0 |

The following therefore applies:

1001_{2} − (−11_{2}) | = | 1001_{2} + 11_{2} |

= | 1100_{2} |

### minuend ist negativ:

If the minuend is negative and the subtrahend is positive, the positive absolute values of the two binary numbers are added first and then a minus sign is written in front of the solution.

For example, the following subtraction is to be performed:

−1001_{2} − 11_{2}

The calculation is made:

1 | 0 | 0 | 1 | |

+ | 1 | 1 | ||

1 | 1 | |||

1 | 1 | 0 | 0 |

So the following applies:

−1001_{2} − 11_{2} | = | −1001_{2} + (−11_{2}) |

= | −(1001_{2} + 11_{2}) | |

= | −1100_{2} |