Arithmetic operations in binary system examples. Binary arithmetic

Note: When adding two numbers equal to 1, 0 is obtained in this digit, and the 1st is transferred to the most significant digit.

Example_21: Numbers 101 (2) and 11 (2) are given. Find the sum of these numbers.

where 101 (2) = 5 (10) , 11 (2) = 3 (10) , 1000 (2) = 8 (10) .

Check: 5+3=8.

When subtracting one from 0, a unit is taken from the highest nearest digit, which is different from 0. At the same time, a unit occupied in the highest digit gives 2 units in the least significant digit and one in all digits between the highest and lowest.

Example_22: Numbers 101 (2) and 11 (2) are given. Find the difference between these numbers.

where 101 (2) =5 (10) , 11 (2) =3 (10) , 10 (2) =2 (10) .

Check: 5-3=2.

The multiplication operation is reduced to repeated shift and addition.

Example_23: Numbers 11 (2) and 10 (2) are given. Find the product of these numbers.

where 11 (2) =3 (10) , 10 (2) =2 (10) , 110 (2) =6 (10) .

Check: 3*2=6.

Arithmetic operations in octal number system

When adding two numbers, the sum of which is equal to 8, in this category, 0 is obtained, and the 1st is transferred to the highest order.

Example_24: Numbers 165 (8) and 13 (8) are given. Find the sum of these numbers.

where 165 (8) = 117 (10) , 13 (8) = 11 (10) , 200 (8) = 128 (10) .

When subtracting a larger number from a smaller number, a unit is taken from the highest nearest digit, which is different from 0. At the same time, a unit occupied in the highest digit gives 8 in the least significant digit.

Example_25: Numbers 114 (8) and 15 (8) are given. Find the difference between these numbers.

where 114 (8) =76 (10) , 15 (8) =13 (10) , 77 (8) =63 (10) .

Arithmetic operations in hexadecimal number system

When adding two numbers, totaling 16, 0 is written in this category, and the 1 is transferred to the highest order.

Example_26: Numbers 1B5 (16) and 53 (16) are given. Find the sum of these numbers.

where 1B5 (16) = 437 (10) , 53 (16) = 83 (10) , 208 (16) = 520 (10) .

When subtracting a larger number from a smaller number, a unit is occupied from the highest nearest digit, which is different from 0. At the same time, a unit occupied in the highest digit gives 16 in the least significant digit.

Example_27: Numbers 11A (16) and 2C (16) are given. Find the difference between these numbers.

where 11A (16) =282 (10) , 2C (16) =44 (10) , EE (16) =238 (10) .

Computer data encoding

Data in a computer is represented as a code, which consists of ones and zeros in different sequences.

The code– a set of symbols for presenting information. Encoding is the process of presenting information in the form of a code.

Number codes

When performing arithmetic operations in a computer, they use direct, reverse and additional number codes.

Direct code

Straight the code (representation in the form of an absolute value with a sign) of a binary number is the binary number itself, in which all the digits representing its value are written as in mathematical notation, and the sign of the number is written as a binary digit.

Integers can be represented in a computer with or without a sign.

Unsigned integers usually occupy one or two bytes of memory. To store signed integers, one, two, or four bytes are allocated, while the most significant (leftmost) bit is allocated under the sign of the number. If the number is positive, then 0 is written to this bit, if negative, then 1.

Example_28:

1 (10) =0 000 0001 (2) , -1 (10) =1 000 0001 (2)


Positive numbers in the computer are always represented using a direct code. The direct code of the number completely coincides with the entry of the number itself in the cell of the machine. The direct code of a negative number differs from the direct code of the corresponding positive number only in the contents of the sign bit.

The direct code is used when storing numbers in computer memory, as well as when performing multiplication and division operations, but the format for representing numbers in a direct code is inconvenient for use in calculations, since addition and subtraction of positive and negative numbers are performed differently, and therefore it is necessary to analyze sign operand bits. Therefore, the direct code is practically not used when implementing arithmetic operations on integers in the ALU. But negative integers are not represented in the computer with a direct code. Instead of this format, formats for representing numbers in reverse and additional codes have become widespread.

Reverse code

Reverse code of a positive number coincides with a direct one, and when writing a negative number, all its digits, except for the digit representing the sign of the number, are replaced by opposite ones (0 is replaced by 1, and 1 is replaced by 0).

Example_29:

Example_30:

To restore the direct code of a negative number from the reverse code, all digits, except for the digit representing the sign of the number, must be replaced with opposite ones.

Additional code

Additional code of a positive number coincides with the direct one, and the code of a negative number is formed by adding 1 to the inverse code.

Example_31:

Example_32:

Example_33:

For an integer -32 (10) write an additional code.

1. After converting the number 32 (10) into the binary number system, we get:

32 (10) =100000 (2) .

2. The direct code for the positive number 32 (10) is 0010 0000.

3. For a negative number -32 (10), the direct code is 1010 0000.

4. The reverse code of the number -32 (10) is 1101 1111.

5. The additional code of the number -32 (10) is 1110 0000.

Example_34:

The additional code of the number is 0011 1011. Find the value of the number in decimal notation.

1. The first (sign) digit of the number 0 011 1011 is 0, so the number is positive.

2. For a positive number, the additional, inverse and direct codes are the same.

3. The number in the binary system is obtained from the record of the direct code - 111011 (2) (we discard zeros from the highest digits).

4. The number 111011 (2) after being converted to the decimal number system is 59 (10).

Example_35:

The additional code of the number is 1011 1011. Find the value of the number in decimal notation.

1. Sign digit of a number 1 011 1011 is 1, so the number is negative.

2. To determine the reverse code of the number, subtract one from the additional code. The reverse code is 1 011 1010.

3. The direct code is obtained from the reverse by replacing all the binary digits of the number with the opposite ones (1 for 0, 0 for 1). The direct code of the number is 1 100 0101 (in the sign bit we write 1).

4. The number in the binary system is obtained from the record of the direct code - -100 0101 (2).

4. The number -1000101 (2) after conversion to decimal is equal to -69 (10).


Similar information.


Service assignment. The online calculator is designed to add binary numbers in direct, inverse and complementary codes.

The following are also used with this calculator:
Converting numbers to binary, hexadecimal, decimal, octal number systems
Multiplication of binary numbers
Floating point format
Example #1. Express the number 133.54 as a floating point number.
Decision. Let's represent the number 133.54 in a normalized exponential form:
1.3354*10 2 = 1.3354*exp 10 2
The number 1.3354*exp 10 2 consists of two parts: the mantissa M=1.3354 and the exponent exp 10 =2
If the mantissa is in the range 1 ≤ M Representing a number in denormalized exponential form.
If the mantissa is in the range 0.1 ≤ M Let's represent the number in denormalized exponential form: 0.13354*exp 10 3

Example #2. Represent the binary number 101.10 2 in a normalized form, write in the 32-bit IEEE754 standard.
truth table


Limit Calculation

Arithmetic in binary system

Arithmetic operations in the binary system are performed in the same way as in decimal. But, if in the decimal number system the transfer and loan are carried out by ten units, then in binary - by two units. The table shows the rules for addition and subtraction in the binary system.
  1. When adding two units in the binary number system, this bit will be 0 and there will be a transfer of one to the highest bit.
  2. When subtracting one from zero, one is borrowed from the highest order, where there is 1 . A unit occupied in this place gives two units in the place where the action is calculated, as well as one, in all intermediate places.

Adding numbers, taking into account their signs on the machine, is a sequence of the following actions:

  • converting the original numbers to the specified code;
  • bitwise addition of codes;
  • analysis of the result.
When performing an operation in the inverse (modified inverse) code, if as a result of addition a carry unit occurs in the sign bit, it is added to the least significant bit of the sum.
When performing an operation in an additional (modified additional) code, if as a result of addition a carry unit occurs in the sign bit, it is discarded.
The operation of subtraction in a computer is performed through addition according to the rule: X-Y=X+(-Y). Further actions are performed in the same way as for the addition operation.

Example #1.
Given: x=0.110001; y= -0.001001, add in reverse modified code.

Given: x=0.101001; y= -0.001101, add in additional modified code.

Example #2. Solve binary subtraction examples using the 1's complement and wrapping method.
a) 11 - 10.
Decision.
Let's represent the numbers 11 2 and -10 2 in the reverse code.

The binary number 0000011 has a return code of 0.0000011

Let's add the numbers 00000011 and 11111101

7 6 5 4 3 2 1 0
1
0 0 0 0 0 0 1 1
1 1 1 1 1 1 0 1
0

7 6 5 4 3 2 1 0
1 1
0 0 0 0 0 0 1 1
1 1 1 1 1 1 0 1
0 0

An overflow occurred in the 2nd bit (1 + 1 = 10). Therefore, we write 0, and transfer 1 to the 3rd bit.
7 6 5 4 3 2 1 0
1 1 1
0 0 0 0 0 0 1 1
1 1 1 1 1 1 0 1
0 0 0

7 6 5 4 3 2 1 0
1 1 1 1
0 0 0 0 0 0 1 1
1 1 1 1 1 1 0 1
0 0 0 0

7 6 5 4 3 2 1 0
1 1 1 1 1
0 0 0 0 0 0 1 1
1 1 1 1 1 1 0 1
0 0 0 0 0

7 6 5 4 3 2 1 0
1 1 1 1 1 1
0 0 0 0 0 0 1 1
1 1 1 1 1 1 0 1
0 0 0 0 0 0

7 6 5 4 3 2 1 0
1 1 1 1 1 1 1
0 0 0 0 0 0 1 1
1 1 1 1 1 1 0 1
0 0 0 0 0 0 0

7 6 5 4 3 2 1 0
1 1 1 1 1 1 1
0 0 0 0 0 0 1 1
1 1 1 1 1 1 0 1
0 0 0 0 0 0 0 0

As a result, we get:
7 6 5 4 3 2 1 0
1 1 1 1 1 1 1
0 0 0 0 0 0 1 1
1 1 1 1 1 1 0 1
0 0 0 0 0 0 0 0

There was a carry from the sign bit. Let's add it (i.e. 1) to the resulting number (thereby carrying out the cyclic transfer procedure).
As a result, we get:
7 6 5 4 3 2 1 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 1

Addition result: 00000001. Convert to decimal representation. To translate the integer part, it is necessary to multiply the digit of the number by the corresponding degree of digit.
00000001 = 2 7 *0 + 2 6 *0 + 2 5 *0 + 2 4 *0 + 2 3 *0 + 2 2 *0 + 2 1 *0 + 2 0 *1 = 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 = 1
Addition result (in decimal notation): 1

b) 111-010 Let's represent the numbers 111 2 and -010 2 in the reverse code.
The reverse code for a positive number is the same as the direct code. For a negative number, all digits of the number are replaced by opposite ones (1 to 0, 0 to 1), and one is entered in the sign bit.
The binary number 0000111 has a return code of 0.0000111
The binary number 0000010 has a return code of 1.1111101
Let's add the numbers 00000111 and 11111101
An overflow occurred in the 0th bit (1 + 1 = 10). Therefore, we write 0, and transfer 1 to the 1st bit.

7 6 5 4 3 2 1 0
1
0 0 0 0 0 1 1 1
1 1 1 1 1 1 0 1
0

An overflow occurred in the 1st bit (1 + 1 = 10). Therefore, we write 0, and transfer 1 to the 2nd bit.
7 6 5 4 3 2 1 0
1 1
0 0 0 0 0 1 1 1
1 1 1 1 1 1 0 1
0 0

An overflow occurred in the 2nd bit (1 + 1 + 1 = 11). Therefore, we write 1, and transfer 1 to the 3rd digit.
7 6 5 4 3 2 1 0
1 1 1
0 0 0 0 0 1 1 1
1 1 1 1 1 1 0 1
1 0 0

An overflow occurred in the 3rd bit (1 + 1 = 10). Therefore, we write 0, and transfer 1 to the 4th bit.
7 6 5 4 3 2 1 0
1 1 1 1
0 0 0 0 0 1 1 1
1 1 1 1 1 1 0 1
0 1 0 0

An overflow occurred in the 4th bit (1 + 1 = 10). Therefore, we write 0, and transfer 1 to the 5th bit.
7 6 5 4 3 2 1 0
1 1 1 1 1
0 0 0 0 0 1 1 1
1 1 1 1 1 1 0 1
0 0 1 0 0

An overflow occurred in the 5th bit (1 + 1 = 10). Therefore, we write 0, and transfer 1 to the 6th bit.
7 6 5 4 3 2 1 0
1 1 1 1 1 1
0 0 0 0 0 1 1 1
1 1 1 1 1 1 0 1
0 0 0 1 0 0

An overflow occurred in the 6th bit (1 + 1 = 10). Therefore, we write 0, and transfer 1 to the 7th bit.
7 6 5 4 3 2 1 0
1 1 1 1 1 1 1
0 0 0 0 0 1 1 1
1 1 1 1 1 1 0 1
0 0 0 0 1 0 0

An overflow occurred in the 7th bit (1 + 1 = 10). Therefore, we write 0, and transfer 1 to the 8th bit.
7 6 5 4 3 2 1 0
1 1 1 1 1 1 1
0 0 0 0 0 1 1 1
1 1 1 1 1 1 0 1
0 0 0 0 0 1 0 0

As a result, we get:
7 6 5 4 3 2 1 0
1 1 1 1 1 1 1
0 0 0 0 0 1 1 1
1 1 1 1 1 1 0 1
0 0 0 0 0 1 0 0

There was a carry from the sign bit. Let's add it (i.e. 1) to the resulting number (thereby carrying out the cyclic transfer procedure).
As a result, we get:
7 6 5 4 3 2 1 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1
0 0 0 0 0 1 0 1

Addition result: 00000101
We got the number 00000101. To translate the integer part, it is necessary to multiply the digit of the number by the degree of the digit corresponding to it.
00000101 = 2 7 *0 + 2 6 *0 + 2 5 *0 + 2 4 *0 + 2 3 *0 + 2 2 *1 + 2 1 *0 + 2 0 *1 = 0 + 0 + 0 + 0 + 0 + 4 + 0 + 1 = 5
Addition result (in decimal notation): 5

Addition of binary floating point real numbers

In a computer, any number can be represented in floating point format. The floating point format is shown in the figure:


For example, the number 10101 in floating point format can be written like this:


Computers use a normalized form of notation, in which the comma position is always set before the significant digit of the mantissa, i.e. condition is met:
b -1 ≤|M| Normalized number - this is a number that has a significant digit after the decimal point (i.e. 1 in the binary number system). Normalization example:
0,00101*2 100 =0,101*2 10
111,1001*2 10 =0,111001*2 101
0,01101*2 -11 =0,1101*2 -100
11,1011*2 -101 =0,11011*2 -11

When adding floating point numbers, the alignment of orders is performed towards a higher order:

Floating point addition algorithm:

  1. Alignment of orders;
  2. Addition of mantissas in the additional modified code;
  3. Normalization of the result.

Example #4.
A=0.1011*2 10 , B=0.0001*2 11
1. Alignment of orders;
A=0.01011*2 11 , B=0.0001*2 11
2. Addition of mantissas in the additional modified code;
MA add. mod. =00.01011
MB additional mod. =00.0001
00,01011
+ 00,00010
=
00,01101
A+B=0.01101*2 11
3. Normalization of the result.
A+B=0.1101*2 10

Example #3. Write a decimal number in binary-decimal notation and add two numbers in binary notation.

Sections: Informatics

Target: teach students how to perform arithmetic operations in the binary system .
Tasks:
educational:
- repetition and consolidation of students' knowledge about number systems;
- to form in schoolchildren the ability to perform correctly arithmetic operations in the binary number system;
developing:
- develop students' logical thinking;
- to develop the cognitive interest of students.

During the classes.

Learning new material.
Addition rules:
0+0=0
0+1=1
1+0=1
1+1=10
Draw students' attention to the fact that when adding two units in the binary number system, the record turns out to be 0, and the unit is transferred to the next digit. When adding three units, 1 is obtained in the record, and the unit is transferred to the next digit. (1+1+1=11).

Example 1
101+10=111

Example 2
10011+11=1110


1001+11=1100
110+110=1100

Multiplication rules:
0*0=0
0*1=0
1*0=0
1*1=1

Example 1
101*11=1111

Explanation:
We multiply each digit of the second factor by each digit of the first factor, the results of the products are added together according to the addition rules in the binary number system. (Mathematics - Grade 3).

Example 2
1011*101=110111

Decision:

Students decide on their own the following examples:
1001*101=101101
1001*11=11011

Subtraction Rules:
0-0=0
1-0=1
1-1=0
0-1=-1
Draw students' attention to the fact that the "minus" in the last rule means - "take the category (1)".

Example 1
10110-111=1111

Explanation:
Subtraction is done in the same way as in mathematics. If the digit in the minuend is less than the digit of the subtrahend, then for this subtraction it is necessary to take the digit (1), because 10-1=1. If there is 0 to the left of such a subtraction, then we cannot take a rank. In this case, we occupy the rank in the minus one at the nearest unit to the left of this subtraction. In this case, all zeros, from which we could not take a digit, must be changed to one, because 0-1=-1. It is advisable to write down all changes in numbers on top of this subtraction. Perform further subtraction with the numbers obtained from above.

Example 2
100000-11=11101

Students decide on their own the following examples:
100010-100=
101011-10111=

Division rule:
The division is performed according to the rules of mathematics, not forgetting that we perform operations in the binary number system.

Example 1
101101:1001=101

Explanation:
In private, we boldly write the first 1, because a number in the binary system cannot start with 0. We multiply this 1 by a divisor, the result is correctly written under the dividend, observing the bit depth. We perform subtraction according to the rules of subtraction in the binary number system. We demolish the next digit of the dividend, and compare the resulting number with the divisor. In this case, the resulting number is less than the divisor; in the quotient, we write 0 (otherwise, 1). We take down the next digit of the dividend. We got a number equal to the divisor, in the quotient we write 1, etc.

Example 2
101010:111=110

Examples for an independent solution:
1001000:1000=1001
111100:1010=110

Homework.
Run actions:
1100+1101=
101+101=
1011*101=
111*101=
11011-110=
10001-1110=
1011010:1010=

Arithmetic operations in positional number systems

Let us consider in more detail arithmetic operations in the binary number system. The arithmetic of the binary number system is based on the use of tables of addition, subtraction and multiplication of digits. Arithmetic operands are located in the top row and in the first column of the tables, and the results are at the intersection of columns and rows:

Let's consider each operation in detail.

Addition. The binary addition table is extremely simple. Only in one case, when the addition is performed 1+1, is transferred to the upper rank. ,

Subtraction. When performing a subtraction operation, a smaller number is always subtracted from a larger number in absolute value and the corresponding sign is put. In the subtraction table, a 1 with a bar means a high order loan.

Multiplication. The multiplication operation is performed using the multiplication table according to the usual scheme used in the decimal number system with successive multiplication of the multiplier by the next digit of the multiplier.

Division. The division operation is performed according to an algorithm similar to the division operation algorithm in the decimal number system.

Converting a number from binary to decimal

The conversion of a number from binary to decimal can be carried out for the integer and fractional parts of the number according to one algorithm by calculating the sum of the products of the digit of the binary number by the weight of its familiarity:

11100011 2 =1*2 7 +1*2 6 +1*2 5 +0*2 4 +0*2 3 +0*2 2 +1*2 1 +1*2 0 =128+64+32+2+1=227 10

0,10100011 2 =1*2 -1 +0*2 -2 +1*2 -3 +0*2 -4 +0*2 -5 ++0*2 -6 +1*2 -7 +1*2 -8 =0.5+0.125+0.0078+0.0039=0.6367

Converting a number from decimal to binary

The conversion of a number from the decimal system to binary is carried out separately for the integer and fractional parts of the number according to the following algorithms:

a) whole decimal number is divided entirely by base 2, then all quotients of integer division are divided by 2, until the quotient is less than the base. The result contains the last quotient and all the remainders of the division, starting with the last one. For example:

convert the number 227 to binary form:

227:2=113 (write the remainder of division 1 into the result), 113:2=56 (write the remainder of division 1 into the result), 56:2=28 (write the remainder of division 0 into the result), 28:2=14 (write the remainder of division 0 into the result), 14:2=7 (write the remainder of division 0 into the result), 7:2=3 (write the remainder of division 1 into the result), 3:2=1 (write the remainder into the result from dividing 1), we write the last quotient in the result - 1. Total we get: 227 10 \u003d 11100011 2. Let's check it back:

1*2 0 +1*2 1 +0*2 2 +0*2 3 +0*2 4 +1*2 5 +1*2 6 +1*2 7 =1+2+32+64+128=227

b) decimal is successively multiplied by base 2, and immediately after each multiplication operation, the resulting integer part is written into the result and is not involved in further multiplication (discarded). The number of multiplication operations depends on the required precision, for example:

let's convert the number 0.64 into binary form:

0.64*2=1.28 (discard 1 and write 1 to result)

0.28*2=0.56 (write 0 into the result)

0.56*2=1.12 (discard 1 and write 1 to result)

0.12*2=0.24 (write 0 into the result)

0.24*2=0.48 (write 0 into the result)

0.48*2=0.96 (write 0 into the result)

0.96*2=1.82 (write 1 into result)

Total: 0.64 10 =0.1010001 2

Let's check it back:

1*2 -1 +0*2 -2 +1*2 -3 +0*2 -4 +0*2 -5 +0*2 -6 +1*2 -7 = 0.5*0+0.125+0+0+0+0.0078=0.6328

Computer representation of negative numbers

It should be borne in mind that binary numbers are stored in computer memory in registers consisting of 8 cells, i.e. the minimum binary number that can be stored in memory must be eight bits. In this case, zeros are written in the unfilled cells of the register (in the highest bits).

Unlike the decimal system, there are no special characters in the binary system that indicate the sign of a number: positive (+) or negative (-), so the following two forms are used to represent binary negative numbers.

Signed value form– the most significant (left) digit is marked as sign and contains information only about the sign of the number:

1 is a negative number, 0 is a positive number.

The remaining digits are reserved for the absolute value of the number.

5 10 = 0000 0101 2 ; -5 10 =1000 0101 2 .

The device of the computer is designed in such a way that negative numbers are represented in an additional code, since this gives a significant time saving when performing arithmetic operations with them.

The form of the reverse additional code, the translation into which is carried out according to the following algorithm:

1) Discard the sign bit;

2) invert all digits of the number;

3) add one to the received code;

4) restore the unit in the sign bit.
For example:

Number conversion -5 10

We write in binary form: 1000 0101; discard the sign bit: 000 0101; invert all digits: 111 1010; add one: 111 1010 + 1 = 111 1011; we restore the unit in the sign bit: 1111 1011. Total -5 10 in the inverse additional code is written as 1111 1011.

Rules for performing arithmetic operations in the binary system

Addition. The addition operation is performed in the same way as in the decimal system. A bit overflow results in a 1 in the next bit:

0+0=0, 0+1=1, 1+1=10;

+ 111011

Subtraction. Since most modern computers have only one hardware adder, which implements all arithmetic operations, subtraction is reduced to addition with a negative number:

Subtraction rules in the binary system. Subtraction operation algorithm by adding additional codes:

1) convert a negative number from a signed form to an additional code;

2) perform a binary addition operation on all digits,
including the signed one, ignoring the carry unit from the highest
discharge;

3) when the sign digit of the sum is equal to one, which means
receiving a negative result in the form of an additional code,
it is necessary to convert the result to the signed form (using the conversion algorithm in the reverse form).

For example, let's perform the action 13-15=13+(-15)

1. We translate -15 into the form of an additional code:

1000 1111 –> 000 1111 -> 111 0000 -> 111 0000 +1=111 0001 -> 1111 0001

2. Add 13 and -15:

+11110001

3. We translate into the usual binary form:

1111 1110 -> 111 1110 ->000 0001 -> 000 0001+1=000 0010 -> 1000 0010 = -2 10

Thus, when performing addition and subtraction operations, the arithmetic logic unit of the processor has to perform bitwise addition with carry, inversion and check for the sign of binary numbers.

In cases where it is necessary to perform arithmetic operations on numbers greater than 127, they are no longer placed in one, but in two or more bytes.

For example, let's perform an action: 15-13=15+(-13)

1. We translate -13 into the form of an additional code:

1000 1101 –> 000 1101 -> 111 0010 -> 111 0010 +1=111 0011 -> 1111 0011

2. Add 15 and -13:

+11110011

3. The sign bit is 0, no reverse translation is required, i.e. the result is 0000 0010=2 10

Multiplication. If, along with the listed operations, perform shift operations, then using the adder, you can also perform multiplication, which reduces to a series of repeated additions. If the digit in the zero position of the multiplier is equal to 1, then the multiplicand is rewritten under the corresponding digits, multiplication by subsequent ones leads to a shift of the term to the left by one position. If the multiplier digit is 0, then the next term is shifted two positions to the left.

For example, let's multiply 6 (0000 0110) by 5 (0000 0101):

*00000101

(multiply by 1) +00000110

(multiply by 0) 1

(multiply by 1) + 0000011011

Check: 0001 1110=0*2 0 +1*2 1 +1*2 2 +1*2 3 +1*2 4 =2+4+8=16=30

For example, let's multiply 15 (0000 1111) by 13 (0000 1101):

*00001101

(multiply by 1) +00001111

(multiply by 0) 1

(multiply by 1) +0000111111

(multiply by 1) + 00001111111

Check: 1100 0011=1*2 7 +1*2 6 +0*2 5 +0*2 4 +0*2 3 +0*2 2 +1*2 1 +1*2 0 =1+2+64 +128=195

Division. When performing a division operation, a subtraction operation is performed several times. Therefore, you must first find an additional divisor code. The division is done by repeatedly subtracting and shifting. For example, let's divide the number 195 (1100 0011) by 15 (0000 1111). The additional code of the number is 0000 1111 -> 11110001. Since, according to the rules of division, each intermediate dividend must be greater than the divisor, we choose the number 11000 as the first dividend, i.e. the first five digits and add three zeros on the left, complementing the dividend to 8 digits. Then we add it with the additional code of the dividend and enter the unit into the result. If the next dividend after the demolition of the next digit is less than the divisor, then zero is entered in the result and one more digit from the original dividend is demolished into the dividend.