Binary operations

daVfn - Sep 12 - - Dev Community

How to do basic mathematical operations with Binary numbers. Here’s an overview of how binary addition, subtraction, multiplication, and division work.

Binary Addition

Just like with decimals, we add binary numbers column by column from the right. For example-1101 + 1011:

1101

  • 1011

=11000

Start from the rightmost column:
1 + 1 = 10 (write 0 and carry 1)
Continue to the left, keeping track of carries.
The result is 11000.

Binary Subtraction

Binary subtraction is also straightforward. If we need to borrow, we take a 1 from the left column:
For example-1001 - 0100:
1001

  • 0100

= 0101

1 - 0 = 1
0 - 1: borrow from the next column, making 2 - 1 = 1.
The result is 101.

Binary Multiplication

Binary multiplication is the same as decimal multiplication. Multiply and then add the results.
For example-1010 x 0110:

1010
x 0110

=111100

Binary Division

Binary division is the same as decimal division, divide, subtract, bring down the next digit.

For example-11100 / 101:

11100 / 101 = 110

.
Terabox Video Player