# Binary subtractor

## World's simplest binary tool

Free online binary difference calculator. Just load your binary values and they will automatically get subtracted from the first value. There are no ads, popups or nonsense, just an awesome binary subtractor. Load binary values – get binary difference. Created for developers by developers from team Browserling.

More tools!
gif tools

We just created Online GIF Tools with dozens of utilities for editing GIFs. Check it out!

A link to this tool, including input, options and all chained tools.

Can't convert.

Binary subtractor tool
What is a binary subtractor?

This tool calculates the difference of binary numbers. It takes two or more binary numbers b1, b2, b3, … and subtracts them b1 - b2 - b3 - …. Binary numbers can have any separator between them and the delimiter character can be configured in the options. The output difference is also displayed in a binary format. As in the process of subtraction the values can get negative, we have implemented several types of signed binary representations for working with negative binary values. The first type is called "Two's Complement" and it's the most popular number representation method for binary number systems. Negative integers are complements of positive integers plus one. For example, given a positive number 101₂ (which is 5 in decimal), we can calculate its negative as follows – first, invert all bits of 101₂ and get 010₂, then add 1 to this result and get 011₂. So, −5₁₀ = 011₂. Things get interesting if we need to use padding. In two's complement scheme, positive numbers are padded with the digit "0" (for example, 5₁₀ = 00000101₂) but negative numbers are padded with the digit "1" (for example, -5₁₀ = 11111011₂). The second representation method is "One's Complement". In this case, a positive number is a regular binary number as you're used to but the negative number is simply its complement (number with all bits inverted). For example, 5₁₀ = 101₂ and -5₁₀ = 010₂. The padding is also "0" for positive numbers (for example, 5₁₀ = 00000101₂) and "1" for negative numbers (for example, -5₁₀ = 11111101₂). The third encoding method is "Signed Bit Representation", also known as "Sign-magnitude Representation" or simply "Sign-and-magnitude". This method uses the most significant bit (MSB) at the beginning of the number to indicate if it's positive or negative. If the MSB is 1, then it's a negative number, if it's 0, then it's a positive number. The number itself doesn't change. For example, 5₁₀ = 0101₂ and -5₁₀ = 1101₂. The padding in this scheme is "0" for both positive and negative numbers. For example, 5₁₀ = 00000101₂ and -5₁₀ = 10000101₂. The fourth type is called "Offset Binary Representation", sometimes known as "Excess-k Code" or "Biased Representation". The key idea in this scheme is that the number -k has all bits set to zero. Usually, k is chosen to be a power of two. For example, in excess-8 (k = 8 = 2

^{3}) representation the number -8 is 0000 and the number 7 (2^{3}-1) is 1111. It's very similar to two's complement method and the only difference is the leading bit. In two's complement, the number -8 is 1000 and the number 7 is 0111. In the offset binary representation the prefix bit "1" indicates a positive binary and the prefix "0" indicates a negative binary but in two's complement, it's the other way around. Here's another example with the number 5. The decimal number 5₁₀ is 1101₂ in excess-8 representation and -5₁₀ is 0011₂. With padding, 5₁₀ is 10000101₂ and -5₁₀ is 01111011₂. The last binary representation method is "Human Subtraction". In this case, the positive and negative numbers differ only in the "-" sign. For example, 5₁₀ is 101 and -5₁₀ is -101. This representation is not used in computers as computers don't have the minus sign and only have bits. In the options, you can quickly switch between these five methods and compare the results. You can customize the padding length, as well as add a binary prefix or suffix. When subtracting several numbers, you can use the option "Running Difference" to see the result at each step of calculation. Finally, for a better understanding of all these binary numbers, we have added an option that displays the decimal result in brackets after each output binary value. Simple and easy!
Binary subtractor examples
Click to use

Subtract Two Binary Numbers

In this example, we find the difference of two binary numbers 1100100 (100 in decimal) and 10100 (20 in decimal). We enter each number on a new line and adjust the separator to "\n". As a result, we get the binary value 1010000, which is 80 in decimal.

1100100
10100

1010000

**Required options**

Simply use the - sign prefix
for a negative binary.

Specify the input separator.

Pad results to this length.

Show how the results are
computed step by step.

Print the decimal number in
parentheses for easier
understanding.

Running Difference

In this example, we subtract three binary numbers and display each subtraction step. To better understand the results, we have activated the "Show Decimal" option as well as "Human Subtraction" method. Thus, we see that 10000₂ - 1010₂ = 110b₂ (6₁₀) and 110₂ - 1000₂ = -10b₂ (-2₁₀). The human subtraction method simply adds a minus sign before positive binary numbers to make them negative.

10000
1010
1000

10000b (16)
110b (6)
-10b (-2)

**Required options**

Simply use the - sign prefix
for a negative binary.

Specify the input separator.

Pad results to this length.

Show how the results are
computed step by step.

Print the decimal number in
parentheses for easier
understanding.

Two's Complement Arithmetic

This example uses the two's complement signed number representation. In this encoding scheme, a negative number is the bit-inverse of the positive number plus one. The example subtracts eight values from the first one and displays partial differences on every line. It also pads positive values with zeros and negative values with ones to the length of 6 and prints the corresponding decimal values in parentheses.

1000
1
10
11
100
101
110
111
1000

001000 (8)
000111 (7)
000101 (5)
000010 (2)
111110 (-2)
111001 (-7)
110011 (-13)
101100 (-20)
100100 (-28)

**Required options**

Represent a negative binary as
an inverted binary plus one.

Specify the input separator.

Pad results to this length.

Show how the results are
computed step by step.

Print the decimal number in
parentheses for easier
understanding.

One's Complement Arithmetic

In this example, we subtract 1 from the number 11 (3 in decimal) eight times and print intermediate differences along the way. The differences are encoded using the one's complement arithmetic. In this numeral system, negative numbers are bit-complement of the positive numbers. After four steps, we reach the first negative number -1₁₀, which is a bit-inverse of 1 and equals 0₂. With 8-bit padding, this number is 11111110₂. Similarly, -2₁₀ is the inverse of 2₁₀ and equals 01₂ or 11111101₂ with padding.

11
1
1
1
1
1
1
1
1

00000011 (3)
00000010 (2)
00000001 (1)
00000000 (0)
11111110 (-1)
11111101 (-2)
11111100 (-3)
11111011 (-4)
11111010 (-5)

**Required options**

Represent a negative binary as
an inverted binary (flip all bits).

Specify the input separator.

Pad results to this length.

Show how the results are
computed step by step.

Print the decimal number in
parentheses for easier
understanding.

Sign and Magnitude Representation

This example subtracts five even numbers, using the signed magnitude representation (SMR). This encoding uses the first bit as the + or - sign indicator. If the most significant bit (MSB) is 0, then it's a + sign and the number is positive. If the MSB is 1, then it's a - sign and the number is negative. The binaries in this example are separated by the "-" character and the running difference and the display decimal value options are enabled. When calculating the third difference, the number becomes negative -4. In SMR -4 is 1100₂. As you can see, 100₂ is 4 and adding a sign bit 1 in front of it makes it 1100₂, which is -4.

110-100-10-100-110

110 (6)
10 (2)
0 (0)
1100 (-4)
11010 (-10)

**Required options**

Set leading bit to 0 for a positive
binary and 1 for a negative binary.

Specify the input separator.

Pad results to this length.

Show how the results are
computed step by step.

Print the decimal number in
parentheses for easier
understanding.

Biased Representation

This example subtracts a bunch of comma-separated binary values using the excess binary (biased binary) representation. In this digital encoding scheme, negative binary values are equal to inverted positive values plus one and with the first bit inverted one more time. This scheme is the same as applying two's complement and then inverting the first bit of the result. In this encoding, positive numbers start with 1 and negative numbers start with 0 but the padding is still 0 for positive numbers and 1 for negative. When using padding, its length sets the k value. In this example, padding is 4 so k is 2

^{padding}= 16. If padding is not set, then each number has the minimal power of two k that it can fit in.
1010, 1000, 110, 100, 10, 110

11010₂ (10)
10010₂ (2)
01100₂ (-4)
01000₂ (-8)
00110₂ (-10)
00000₂ (-16)

**Required options**

Similar to two's complement, but
with the first bit flipped.

Specify the input separator.

Pad results to this length.

Show how the results are
computed step by step.

Print the decimal number in
parentheses for easier
understanding.

Pro tips
Master online binary tools

You can pass input to this tool via

__?input__query argument and it will automatically compute output. Here's how to type it in your browser's address bar. Click to try!
https://onlinebinarytools.com/subtract-binary-numbers

__?input__=1100100%0A10100&input-separator=%5Cn&human=true&padding-length=0&prefix=without-prefix&running-difference=false&show-decimal=false
All binary tools

Quickly convert ASCII characters to binary numbers.

Quickly convert binary numbers to ASCII characters.

Quickly convert UTF8 characters to binary bits.

Quickly convert binary bits to UTF8 characters.

Quickly generate random binary values.

Quickly create an image from a binary number.

Quickly convert binary numbers to octal numbers.

Quickly convert octal numbers to binary numbers.

Quickly convert binary numbers to decimal numbers.

Quickly convert decimal numbers to binary numbers.

Quickly convert binary numbers to hexadecimal numbers.

Quickly convert hexadecimal numbers to binary numbers.

Quickly convert octal values to BCD values.

Quickly convert BCD values to octal values.

Quickly convert decimal values to BCD values.

Quickly convert BCD values to decimal values.

Quickly convert hex values to BCD values.

Quickly convert BCD values to hex values.

Quickly convert an IP address to a binary IP address.

Quickly convert a binary IP address to a human readable IP.

Quickly convert an IPv6 address to a binary IPv6 address.

Quickly convert a binary IPv6 address to a human readable IPv6.

Quickly convert a string to binary values.

Quickly convert binary values to a string.

Quickly convert binary numbers to reflected binary numbers.

Quickly convert reflected binary numbers to binary numbers.

Quickly convert octal numbers to reflected binary numbers.

Quickly convert reflected binary numbers to octal numbers.

Quickly convert decimal numbers to reflected binary numbers.

Quickly convert reflected binary numbers to decimal numbers.

Quickly convert hexadecimal numbers to Gray code.

Quickly convert Gray code to hexadecimal numbers.

Quickly calculate the sum of a bunch of binary values.

Quickly calculate the difference of a bunch of binary values.

Quickly calculate the product of a bunch of binary values.

Quickly convert a negative number to a binary representation.

Quickly convert a negative binary number to a decimal number.

Quickly convert base 2 numbers to base -2.

Quickly calculate bitwise AND of a bunch of binary values.

Quickly calculate bitwise NAND of a bunch of binary values.

Quickly calculate bitwise OR of a bunch of binary values.

Quickly calculate bitwise NOR of a bunch of binary values.

Quickly calculate bitwise XOR of a bunch of binary values.

Quickly calculate bitwise XNOR of a bunch of binary values.

Quickly calculate bitwise NOT of a bunch of binary values.

Quickly find the number of high bits in binary values.

Quickly find the number of low bits in binary values.

Quickly invert bits of binary numbers.

Quickly reverse the order of bits in binary numbers.

Quickly convert plain text to binary values.

Quickly convert binary numbers to plain text.

Quickly randomize the order of bits in binary numbers.

Quickly rotate bits in binary numbers to the left or right.

Quickly shift bits of a binary number to the left.

Quickly shift bits of a binary number to the right.

Coming soon
These binary tools are on the way

Create a File from Binary Values

Convert binary numbers to a binary file.

Binary Dump a File

Create a binary dump of files in your browser.

Convert Binary to Arbitrary Base

Convert binary values to any base (up to base 64).

Convert Binary to Roman Number

Convert binary numbers to Roman numerals.

Convert Roman Number to Binary

Convert Roman numerals to binary values.

Generate a Binary Sequence

Create a list of increasing of decreasing binary numbers.

Binary Sheffer Stroke

Calculate bitwise sheffer stroke operator of binary values.

Convert Binary to BCD

Encode every binary bit as a binary coded decimal.

Convert BCD to Binary

Decode binary coded decimals to binary bits.

Divide Binary Numbers

Perform division operation on several binary numbers.

Rotate a Binary Right

Rotate bits of a binary number to the right.

Rotate a Binary Left

Rotate bits of a binary number to the left.

Extract Bits from Binary Numbers

Extract n-th bit from a binary number.

Calculate Parity

Count parity of a binary number.

Convert EBCDIC to Binary

Convert EBCDIC characters to binary values.

Convert Binary to EBCDIC

Convert binary bits to EBCDIC symbols.

Swap Binary Endianness

Change endianness of a binary number.

Convert Little Endian Binary to Big Endian Binary

Convert a binary number from little endian to big endian.

Convert Big Endian Binary to Little Endian Binary

Convert a binary number from big endian to little endian.

Convert a Floating Point Number to Binary

Find the binary representation of a floating point number.

Convert Binary Values to a Bitmap

Convert a binary string to a bitmap image.

Convert a Bitmap to Binary Numbers

Convert a bitmap image to zeros and ones.

Split Binary Values

Split a binary number into smaller binary numbers.

Join Binary Values

Join multiple smaller binary numbers into a single binary.

Slice Binary Values

Extract a part of a binary number.

Pad Binary Values

Add signed or unsigned padding to binary numbers.

Truncate Binary Values

Drop leading or trailing bits and make a binary value shorter.

Randomly Flip Binary Bits

Introduce random errors in binary values.

Analyze Binary Data

Print statistics of the input binary values.

Subscribe!
Never miss an update

Cool!

Notifications
We'll let you know when we add this tool

Cool!