9010 SayPro Lesson 1.4 BINARY ARITHMETIC

Email: info@saypro.online Call/WhatsApp: + 27 84 313 7407

SayPro is a Global Solutions Provider working with Individuals, Governments, Corporate Businesses, Municipalities, International Institutions. SayPro works across various Industries, Sectors providing wide range of solutions.

Arithmetic in binary is much like arithmetic in other numeral systems. Addition, subtraction, multiplication, and division can be performed on binary numerals.

1.3.1 Addition

The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:

0 + 0 → 0

0 + 1 → 1

1 + 0 → 1

1 + 1 → 0, carry 1 (since 1 + 1 = 0 + 1 × binary 10)

Adding two “1” digits produces a digit “0”, while 1 will have to be added to the next column. This is similar to what happens in decimal when certain single-digit numbers are added together; if the result equals or exceeds the value of the radix (10), the digit to the left is incremented:

5 + 5 → 0, carry 1 (since 5 + 5 = 10 carry 1)

7 + 9 → 6, carry 1 (since 7 + 9 = 16 carry 1)

This is known as carrying. When the result of an addition exceeds the value of a digit, the procedure is to “carry” the excess amount divided by the radix (that is, 10/10) to the left, adding it to the next positional value. This is correct since the next position has a weight that is higher by a factor equal to the radix. Carrying works the same way in binary:

 

Example  1 1 1 1 1            (carried digits)     0 1 1 0 1+   1 0 1 1 1     ————-= 1 0 0 1 0 0 = 36 

In this example, two numerals are being added together: 011012 (1310) and 101112 (2310). The top row shows the carry bits used. Starting in the rightmost column 1 + 1 = 102. The 1 is carried to the left, and the 0 is written at the bottom of the rightmost column. The second column from the right is added: 1 + 0 + 1 = 102 again; the 1 is carried, and 0 is written at the bottom. The third column: 1 + 1 + 1 = 112. This time, a 1 is carried, and a 1 is written in the bottom row. Proceeding like this gives the final answer 1001002 (36 decimal).

A simplification for many binary addition problems is the Long Carry Method or Brook house Method of Binary Addition. This method is generally useful in any binary addition where one of the numbers has a long string of “1” digits. For example the following large binary numbers can be added in two simple steps without multiple carries from one place to the next.

Example1 1 1   1 1 1 1 1      (carried digits)                   (Long Carry Method)     1 1 1 0 1 1 1 1 1 0                                             1 1 1 0 1 1 1 1 1 0+   1 0 1 0 1 1 0 0 1 1            versus:               +   1 0 1 0 1 1 0 0 1 1       add crossed out digits first       ———————–                                      + 1 0 0 0 1 0 0 0 0 0 0 = sum of crossed out digits= 1 1 0 0 1 1 1 0 0 0 1                                          ———————–          now add remaining digits                                                                            1 1 0 0 1 1 1 0 0 0 1


In this example, two numerals are being added together: 1 1 1 0 1 1 1 1 1 02 (95810) and 1 0 1 0 1 1 0 0 1 12 (69110). The top row shows the carry bits used. Instead of the standard carry from one column to the next, the lowest place-valued “1” with a “1” in the corresponding place value beneath it may be added and a “1” may be carried to one digit past the end of the series. These numbers must be crossed off since they are already added. Then simply add that result to the uncanceled digits in the second row. Proceeding like this gives the final answer 1 1 0 0 1 1 1 0 0 0 12 (164910).

1.3.2 Subtraction

Subtraction works in much the same way:

0 − 0 → 0

0 − 1 → 1, borrow 1

1 − 0 → 1

1 − 1 → 0

Subtracting a “1” digit from a “0” digit produces the digit “1”, while 1 will have to be subtracted from the next column. This is known as borrowing. The principle is the same as for carrying. When the result of a subtraction is less than 0, the least possible value of a digit, the procedure is to “borrow” the deficit divided by the radix (that is, 10/10) from the left, subtracting it from the next positional value.   *   * * *   (starred columns are borrowed from)

Example

1 1 0 1 1 1 0−        1 0 1 1 1       —————-=   1 0 1 0 1 1 1

 

  

Subtracting a positive number is equivalent to adding a negative number of equal absolute value; computers typically use two’s complement notation to represent negative values. This notation eliminates the need for a separate “subtract” operation. Using two’s complement notation subtraction can be summarized by the following formula:

A − B = A + not B + 1.

1.3.3 Multiplication

Multiplication in binary is similar to its decimal counterpart. Two numbers A and B can be multiplied by partial products: for each digit in B, the product of that digit in A is calculated and written on a new line, shifted leftward so that its rightmost digit lines up with the digit in B that was used. The sum of all these partial products gives the final result.

Since there are only two digits in binary, there are only two possible outcomes of each partial multiplication:

  • If the digit in B is 0, the partial product is also 0
  • If the digit in B is 1, the partial product is equal to A

Example

The binary numbers 1011 and 1010 are multiplied as follows:

           1 0 1 1   (A)         × 1 0 1 0   (B)         ———           0 0 0 0   ← Corresponds to a zero in B   +     1 0 1 1     ← Corresponds to a one in B   +   0 0 0 0   + 1 0 1 1   —————   = 1 1 0 1 1 1 0

Binary numbers can also be multiplied with bits after a binary point:

               1 0 1.1 0 1   (A) (5.625 in decimal)             × 1 1 0.0 1     (B) (6.25  in decimal)             ————-                   1.0 1 1 0 1   ← Corresponds to a one in B     +           0 0.0 0 0 0     ← Corresponds to a zero in B     +         0 0 0.0 0 0     +       1 0 1 1.0 1     +     1 0 1 1 0.1     ———————–     =   1 0 0 0 1 1.0 0 1 0 1   (35.15625 in decimal)

See also Booth’s multiplication algorithm.

1.3.4 Division

Binary division is again similar to its decimal counterpart:

Here, the divisor is 1012, or 5 decimal, while the dividend is 110112, or 27 decimal. The procedure is the same as that of decimal long division; here, the divisor 1012 goes into the first three digits 1102 of the dividend one time, so a “1” is written on the top line. This result is multiplied by the divisor, and subtracted from the first three digits of the dividend; the next digit (a “1”) is included to obtain a new three-digit sequence:

              1            ___________1 0 1   ) 1 1 0 1 1         − 1 0 1          —–                  0 1 1

The procedure is then repeated with the new sequence, continuing until the digits in the dividend have been exhausted:

             1 0 1       ___________1 0 1  ) 1 1 0 1 1       − 1 0 1         —–           0 1 1         − 0 0 0           —–             1 1 1           − 1 0 1             —–               1 0

Thus, the quotient of 110112 divided by 1012 is 1012, as shown on the top line, while the remainder, shown on the bottom line, is 102. In decimal, 27 divided by 5 is 5, with a remainder of 2.

Exercise

1.Adding two binary numbers

Add the binary numbers 11102 and 1112

What are the above numbers in decimal numbers and what is the total

2.Adding multiple binary numbers

a. An easy way to calculate the correct number of carries is to        _____________________ and mark a carry in the next column for each pair.

b. Demonstrate how to add the numbers 1112, 1102, 11002, 1012, and 11112. Check your

answer by calculating the decimal numbers for the above.

  • Neftaly Malatjie | CEO | SayPro
  • Email: info@saypro.online
  • Call: + 27 84 313 7407
  • Website: www.saypro.online

SayPro ShopApp Jobs Courses Classified AgriSchool Health EventsCorporate CharityNPOStaffSports

Comments

Leave a Reply