Addition of binary numbers. Addition of binary numbers Arithmetic operations in binary number system

Tasks for determining values ​​in various number systems and their bases

Exercise 1. The characters @, $, &, % are encoded in two-digit consecutive binary numbers. The first character corresponds to the number 00. Using these characters, the following sequence was encoded: $% [email protected]$. Decode this sequence and convert the result to hexadecimal.

Solution.

1. Let's compare the binary numbers to the characters they encode:
00 — @, 01 — $, 10 — &, 11 — %

3. Let's translate the binary number into the hexadecimal number system:
0111 1010 0001 = 7A1

Answer. 7A1 16 .

Task 2. There are 100 x fruit trees in the garden, of which 33 x are apple trees, 22 x …
- pears, 16 x - plums, 17 x - cherries. What is the base of the number system (x).

Solution.

1. Note that all terms - double figures. In any number system, they can be represented as follows:
a * x 1 + b * x 0 = ax + b, where a and b are the digits of the corresponding digits of the number.
For a three digit number it would be like this:
a * x 2 + b * x 1 + c * x 0 = ax 2 + bx + c

2. The condition of the problem is as follows:
33x + 22x + 16x + 17x = 100x
Substitute the numbers in the formulas:
3x + 3 + 2x +2 + 1x + 6 + 1x + 7 = 1x 2 + 0x + 0
7x + 18 = x2

3. Solve the quadratic equation:
-x2 + 7x + 18 = 0
D \u003d 7 2 - 4 * (-1) * 18 \u003d 49 + 72 \u003d 121. Square root from D is 11.
Roots quadratic equation:
x = (-7 + 11) / (2 * (-1)) = -2 or x = (-7 - 11) / (2 * (-1)) = 9

4. A negative number cannot be the base of the number system. So x can only be equal to 9.

Answer. The desired base of the number system is 9.

Task 3. In a number system with some base, the decimal number 12 is written as 110. Find this base.

Solution.

First, let's write the number 110 through the formula for writing numbers in positional number systems to find the value in the decimal number system, and then find the base by brute force.

110 = 1 * x 2 + 1 * x 1 + 0 * x 0 = x 2 + x

We need to get 12. We try 2: 2 2 + 2 = 6. We try 3: 3 2 + 3 = 12.

So the base of the number system is 3.

Answer. The desired base of the number system is 3.

Hexadecimal and octal number systems

Exercise 1. What number in hexadecimal number corresponds to the number 11000101?

Solution.

When converting a binary number to hexadecimal, the first is divided into groups of four digits, starting from the end. If the number of digits is not divisible by four, then the first four is added with zeros in front. Each quadruple uniquely corresponds to one digit of the hexadecimal number system.

11000101 = 1100 0101 = C5 16

There is no need to have a correspondence table in front of your eyes. Binary counting of the first 15 numbers can be done in the mind or sequentially painted. It should not be forgotten that 10 in decimal corresponds to A in hexadecimal, 11 to B, 12 to C, 13 to D, 14 to E, 15 to F.

Answer. 11000101 = C5 16

Task 2. Calculate the sum of the binary numbers x and y, with x = 10100 and y = 10101. Express the results as an octal number.

Solution.

Let's add two numbers. The rules for binary and decimal arithmetic are the same:

When converting a binary number to octal, the first is divided into groups of three digits, starting from the end. If the number of digits is not divisible by three, then the first three are added with zeros in front:

Answer. The sum of the binary numbers 10100 and 10101, represented in octal, is 51.

Convert to binary number system

Exercise 1. What is the number 37 in binary number system?

Solution.

You can convert by dividing by 2 and combining the remainders in reverse order.

Another way is to expand the number into the sum of powers of two, starting with the highest, the calculated result of which is less than the given number. When converting, the missing powers of a number should be replaced with zeros:

37 10 = 32 + 4 + 1 = 2 5 + 2 2 + 2 0 = 1 * 2 5 + 0 * 2 4 + 0 * 2 3 + 1 * 2 2 + 0 * 2 1 + 1 * 2 0 = 100101

Answer. 37 10 = 100101 2 .

Task 2. How many significant zeros are in binary notation decimal number 73?

Solution.

We decompose the number 73 into the sum of powers of two, starting with the highest and multiplying the missing powers by zeros, and the existing ones by one:

73 10 = 64 + 8 + 1 = 2 6 + 2 3 + 2 0 = 1 * 2 6 + 0 * 2 5 + 0 * 2 4 + 1 * 2 3 + 0 * 2 2 + 0 * 2 1 + 1 * 2 0 = 1001001

Answer. There are four significant zeros in the binary notation for the decimal number 73.

Task 3. Calculate the sum of x and y for x = D2 16 , y = 37 8 . Present the result in binary number system.

Solution.

Recall that each digit of a hexadecimal number is formed by four binary digits, each digit of an octal number by three:

D2 16 = 1101 0010
37 8 = 011 111

Let's add the numbers:

Answer. The sum of the numbers D2 16 and y = 37 8 , represented in the binary system, is 11110001.

Task 4. Given: a= D7 16 , b= 331 8 . Which of the numbers c, written in binary notation, meets the condition a< c < b ?

  1. 11011001
  2. 11011100
  3. 11010111
  4. 11011000

Solution.

Let's translate the numbers into the binary number system:

D7 16 = 11010111
331 8 = 11011001

The first four digits for all numbers are the same (1101). Therefore, the comparison is simplified to a comparison of the least significant four digits.

The first number in the list is the number b, therefore, does not fit.

The second number is greater than b. The third number is a.

Only the fourth number fits: 0111< 1000 < 1001.

Answer. The fourth option (11011000) meets the condition a< c < b .

Convert to decimal number system

Exercise 1. What number in the decimal number system corresponds to the number 24 16?

Solution.

24 16 = 2 * 16 1 + 4 * 16 0 = 32 + 4 = 36

Answer. 24 16 = 36 10

Task 2. It is known that X = 12 4 + 4 5 + 101 2 . What is the number X in decimal notation?

Solution.


12 4 = 1 * 4 1 + 2 * 4 0 = 4 + 2 = 6
4 5 = 4 * 5 0 = 4
101 2 = 1 * 2 2 + 0 * 2 1 + 1 * 2 0 = 4 + 0 + 1 = 5
Find the number: X = 6 + 4 + 5 = 15

Answer. X = 15 10

Task 3. Calculate the value of the sum 10 2 + 45 8 + 10 16 in decimal notation.

Solution.

Let's translate each term into the decimal number system:
10 2 = 1 * 2 1 + 0 * 2 0 = 2
45 8 = 4 * 8 1 + 5 * 8 0 = 37
10 16 = 1 * 16 1 + 0 * 16 0 = 16
The sum is: 2 + 37 + 16 = 55

Answer. 55 10

Arithmetic operations in binary system

Number systems

Topic number:

In the binary number system, arithmetic operations are performed according to the same rules as in the decimal number system, because they are both positional (along with octal, hexadecimal, etc.).

Addition

The addition of single-digit binary numbers is performed according to the following rules:

In the latter case, when two units are added, the low-order bit overflows, and the unit is transferred to the high-order bit. Overflow occurs if the sum is equal to the base of the number system (in this case, this is the number 2) or more than it (for the binary number system, this is not relevant).

For example, let's add any two binary numbers:

Subtraction

Subtraction of single-digit binary numbers is performed according to the following rules:

0 - 1 = (high order borrowing) 1

Multiplication

Multiplication of single-digit binary numbers is performed according to the following rules:

Division

Division is performed in the same way as in the decimal number system:

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.
Solution. 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.
Solution.
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 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 notation for a number, in which the comma position is always given before significant figure 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.

Example 1. Find X if To transform the left side of the equality, we successively use de Morgan's law for logical addition and the law of double negation: According to the distributive law for logical addition: According to the law of elimination of the third and the law of constant elimination: Equate the resulting left side with the right: X \u003d B Finally, we get: X = B. Example 2. Simplify the logical expression Verify the correctness of the simplification using truth tables for the original and resulting logical expression. According to the law of general inversion for logical addition (De Morgan's first law) and the law of double negation: According to the distributive (distributive) law for logical addition: According to the law of contradiction: According to the law of idempotence We substitute the values ​​and, using the commutative (commutative) law and grouping the terms, we obtain : According to the law of exclusion (gluing) Substitute the values ​​and get: According to the law of exclusion of constants for logical addition and the law of idempotence: Substitute the values ​​and get: According to the distributive (distributive) law for logical multiplication: According to the law of elimination of the middle: Substitute the values ​​and finally get: 2 The logical foundations of a computer A discrete converter, which, after processing the input binary signals, outputs a signal at the output, which is the value of one of the logical operations, is called a logical element. Below are the symbols (schemes) of basic logical elements that implement logical multiplication (conjunctor), logical addition (disjunctor) and negation (inverter). Rice. 3.1. Conjunctor, disjunctor and inverter Computer devices (adders in the processor, memory cells in RAM, etc.) are built on the basis of basic logic elements. Example 3. Based on the given logical function F(A, B) = =B&AÚB&A, construct a logical circuit. The construction must begin with a logical operation, which must be performed last. In this case, such an operation is a logical addition, therefore, there must be a disjunctor at the output of the logical circuit. Signals are fed to it from two conjunctors, which, in turn, are supplied with one input signal normal and one inverted (from inverters). Example 4. The logic circuit has two inputs X and Y. Determine the logic functions F1(X,Y) and F2(X,Y) that are implemented at its two outputs. The function F1(X,Y) is implemented at the output of the first conjunctor, that is, F1(X,Y) = X&Y. At the same time, the signal from the conjunctor is fed to the input of the inverter, at the output of which the X&Y signal is realized, which, in turn, is fed to one of the inputs of the second conjunctor. The signal Xv Y from the disjunctor is fed to the other input of the second conjunctor, therefore, the function F2(X,Y) = X&Y&,(XvY). Consider the scheme of adding two n-bit binary numbers. When adding the digits of the i-ro digit, ai and bi are added, as well as Pi-1 - a transfer from the i-1 digit. The result will be st - the sum and Pi - the transfer to the high order. Thus, a one-bit binary adder is a device with three inputs and two outputs. Example 3.15. Construct a truth table for a one-bit binary adder using the binary addition table. Trigger. Triggers are used to store information in the RAM of the computer, as well as in the internal registers of the processor. The trigger can be in one of two stable states, which allows you to remember, store and read 1 bit of information. The simplest trigger is the .RS trigger. It consists of two OR-NOT gates that implement the logic function F9 (see table 3.1). The inputs and outputs of the elements are connected by a ring: the output of the first is connected to the input of the second and the output of the second is connected to the input of the first. The trigger has two inputs S (from the English set - installation) and I (from the English reset - reset) and two outputs Q (direct) and Q (inverse). Rice. 2 RS flip-flop logic Example 3.16. Construct a table describing the state of the inputs and outputs of the RS flip-flop. If the inputs receive signals R = 0 and S = 0, then the trigger is in storage mode, the outputs Q and Q retain the previously set values. If a signal 1 is supplied to the setting input S for a short time, then the trigger goes into state 1 and after the signal at input S becomes equal to 0, the trigger will save this state, that is, it will store 1. When 1 is applied to input R, the trigger will go to state 0. Applying a logical one to both inputs S and R can lead to an ambiguous result, so this combination of input signals is prohibited. Tasks for self-fulfillment 1. There are 16 logical functions of two variables (see table 3.1). Build their logic circuits using basic logic elements: conjunctor, disjunctor and inverter. 2. Prove that the logic circuit considered in Example 3.10 is a one-bit binary half-adder (carry from the least significant bit is not taken into account). 3. Prove by constructing a truth table that the logical function Р = (A&B)v(A&,P0)v(B&P0) determines the transfer to the highest bit when adding binary numbers (A and B are terms, Po is a carry from the least significant bit). 4. Prove by constructing a truth table that the logical function S = (AvBvP0)&Pv(A&.B&P0) determines the sum when adding binary numbers (A and B are terms, Po is a carry from the least significant bit). 5. Build a logic circuit of a single-bit binary adder. How many basic gates are required to implement a 64-bit binary adder? 6. How many basic logical elements form the RAM of a modern computer with a capacity of 64 MB? 1. Write down the numbers in expanded form: a) A8=143511; d) A10=143.511; 6)A2=100111; e) A8=0.143511; c) A16=143511; e) A1e \u003d 1AZ, 5C1. 2. Write down the following numbers in folded form: a) A10 \u003d 9-101 + 1 * 10 + 5 "10-1 + 3-10 ~ 2; b) A16 \u003d A-161 + 1-16 ° + 7-16" 1+5-16~2. 3. Are the numbers written correctly in the corresponding number systems: a) A10 = A,234; c) A16=456.46; b) A8 = -5678; d) A2=22.2? 4. What is the minimum base of the number system if the numbers 127, 222, 111 are written in it? Determine the decimal equivalent of these numbers in the found number system. 5. What is the decimal equivalent of the numbers 101012, 101018 1010116? 6. A three-digit decimal number ends with the number 3. If this figure is moved two digits to the left, that is, a new number will begin recording from it, then this new number will be one more than triple the original number. Find the original number. 2.22. A six-digit decimal number begins on the left with the number 1. If this figure is transferred from the first place on the left to the last place on the right, then the value of the formed number will be three times the original. Find the original number. 2.23. Which of the numbers 1100112, 1114, 358 and 1B16 is: a) the largest; b) the least? 2.27. Is there a triangle whose side lengths are expressed by the numbers 12g, 1116 and 110112? 2.28. What is the largest decimal number that can be written as three digits in binary, octal and hexadecimal number systems? 2.29. "Not serious" questions. When is 2x2=100? When is 6x6=44? When is 4x4=20? 2.30. Write down the whole decimal numbers belonging to the following numerical intervals: a) ; b) ; in) . 2.31. There are 11112 girls and 11002 boys in the class. How many students are in the class? 2.32. There are 36d students in the class, of which 21q are girls and 15q are boys. What numbering system was used to count students? 2. 33. There are 100q fruit trees in the garden, of which 33q are apple trees, 22q pear trees, 16q plums and 5q cherries. In what number system are the trees counted? 2.34. There were 100q apples. After each of them was cut in half, there were 1000q halves. In the number system, with what basis was the account kept? 2.35. I have 100 brothers. The younger one is 1000 years old, and the older one is 1111 years old. The eldest is studying in class 1001. Could this be? 2.36. Once upon a time there was a pond in the center of which grew a single leaf of a water lily. Every day the number of such leaves doubled, and on the tenth day the entire surface of the pond was already filled with lily leaves. How many days did it take to fill half the pond with leaves? How many leaves were there after the ninth day? 2.37. By selecting the powers of the number 2, which add up to a given number, convert the following numbers into the binary number system: a) 5; at 12; e) 32; b) 7; d) 25; f) 33. Check the correctness of the translation using the Advanced Converter program. 2.3. Translation of numbers from one number system to another 2.3.1. Converting integers from one number system to another We can formulate an algorithm for converting integers from a system with base p to a system with base q: 1. Express the base of the new number system in terms of the digits of the original number system and perform all subsequent actions in the original number system. 2. Sequentially perform the division of the given number and the resulting integer quotients by the basis of the new number system until we get a quotient less than the divisor. 3. The resulting remainders, which are the digits of a number in the new number system, are brought into line with the alphabet of the new number system. 4. Compose a number in the new number system, writing it down starting from the last remainder. Example 2.12. Convert the decimal number 17310 to octal: ■ We get: 17310=2558. Example 2.13. Convert decimal number 17310 to hexadecimal number system: - We get: 17310=AD16. Example 2.14 Convert decimal number 1110 to binary number system. We get: 111O=10112. Example 2.15. Sometimes it is more convenient to write the translation algorithm in the form of a table. Let's convert the decimal number 36310 to a binary number. 2.3.2. Converting fractional numbers from one number system to another We can formulate an algorithm for converting a proper fraction with base p into a fraction with base q: 1. Express the base of the new number system in terms of the digits of the original number system and perform all subsequent actions in the original number system. 2. Sequentially multiply the given number and the resulting fractional parts of the products by the basis of the new system until the fractional part of the product becomes equal to zero or the required accuracy of the representation of the number is reached. 3. The resulting integer parts of the products, which are the digits of a number in the new number system, must be brought into line with the alphabet of the new number system. 4. Compose the fractional part of the number in the new number system, starting with the integer part of the first product. Example 2.16. Convert 0.6562510 to octal number system. Example 2.17. Convert the number 0.6562510 to hexadecimal number system. Example 2.18. Convert decimal 0.562510 to binary number system. Example 2.19. Convert the decimal fraction 0.710 to binary. Obviously, this process can continue indefinitely, giving more and more new signs in the image of the binary equivalent of the number 0.710. So, in four steps we get the number 0.10112, and in seven steps we get the number 0.10110012, which is a more accurate representation of the number 0.710 in binary, and so on. Such an endless process is interrupted at a certain step, when it is considered that the required accuracy of the representation of the number has been obtained. 2.3.3. Translation of arbitrary numbers Translation of arbitrary numbers, that is, numbers containing integer and fractional parts, is carried out in two stages. The whole part is translated separately, the fractional part is translated separately. In the final record of the resulting number, the integer part is separated from the fractional comma. Example 2.20. Convert the number 17.2510 to the binary number system. We translate the integer part: We translate the fractional part: Example 2.21. Convert the number 124.2510 to octal. 2.3.4. Translation of numbers from a number system with base 2 to a number system with base 2n and vice versa Translation of integers - If the base of the q-ary number system is a power of 2, then the translation of numbers from the q-ary number system to binary and vice versa can be carried out using simpler rules. In order to write a binary integer in a number system with base q \u003d 2 ", you need to: 1. Divide the binary number from right to left into groups of n digits each. 2. If the last left group contains less than n digits, then it must add zeros to the left to the required number of digits 3. Consider each group as an n-digit binary number and write it down as the corresponding digit in the number system with base q = 2n Example 2.22 Convert the number 1011000010001100102 to the octal number system. We divide the number from right to left into triads and write the corresponding octal digit under each of them: We get the octal representation of the original number: 5410628. Example 2.23. Let's convert the number 10000000001111100001112 to hexadecimal number system. We divide the number from right to left into tetrads and write the corresponding hexadecimal digit under each of them: We get the hexadecimal representation of the original number: 200F8716. Translation of fractional numbers. In order to write a fractional binary number in a number system with base q \u003d 2 ", you need to: 1. Divide the binary number from left to right into groups of n digits each. 2. If the last right group contains less than n digits, then its 3. Consider each group as an n-digit binary number and write it down with the corresponding digit in the number system with base q = 2n Example 2.24. to the right into triads and under each of them we write the corresponding octal digit: We get the octal representation of the original number: 0.5428 Example 2.25 We translate the number 0.1000000000112 into the hexadecimal number system Divide the number from left to right into tetrads and write under each of them corresponding hexadecimal digit: Get the hexadecimal representation of the original number: 0.80316. write a binary number in a number system with base q - 2n, you need: [ 1. Divide the integer part of this binary number from right to left, and the fractional part from left to right into groups of n digits each. 2. If there are less than n digits in the last left and/or right groups, then they must be supplemented on the left and/or right with zeros to the required number of digits. 3. Consider each group as an n-bit binary number and write it down as the corresponding digit in the number system with base q = 2n. Example 2.26. Let's translate the number 111100101.01112 into the octal number system. We divide the integer and fractional parts of the number into triads and write the corresponding octal digit under each of them: We get the octal representation of the original number: 745.34S. Example 2.27. Let's translate the number 11101001000,110100102 into the hexadecimal number system. We divide the integer and fractional parts of the number into tetrads and write the corresponding hexadecimal digit under each of them: We get the hexadecimal representation of the original number: 748,D216. Translation of numbers from number systems with base q \u003d 2p to a binary system. In order for an arbitrary number written in a number system with base q \u003d 2 to be converted to a binary number system, you need to replace each digit of this number with its n-digit equivalent in the binary number system . Example 2.28. Let's translate the hexadecimal number 4AC351b into the binary number system. In accordance with the algorithm: i We get: 10010101100001101012 Tasks for self-fulfillment 2.38. Fill in the table, in each line of which the same integer must be written in different number systems. 2.39. Fill in the table, in each line of which the same fractional number must be written in different number systems. 2.40. Fill in the table, in each line of which the same arbitrary number (the number can contain both an integer and a fractional part) must be written in different number systems. 2.4. Arithmetic operations in positional number systems

Arithmetic operations in the binary system.


Example 2.29. Consider a few examples of adding binary numbers:

Subtraction. When performing a subtraction operation, the smaller number is always subtracted from the 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.


Example 2.31. Consider a few examples of binary multiplication:

You see that multiplication comes down to multiplicand shifts and additions.

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


Addition in other number systems. Below is the addition table in octal number system:

2.42. Arrange the signs of arithmetic operations so that the following equalities are true in the binary system:

Write the answer for each number in the indicated and decimal number systems. 2.44. Which number precedes each of the data:

2.45. Write out the integers belonging to the following numerical intervals:

a) in binary system;

b) in the octal system;

c) in hexadecimal system.

Write the answer for each number in the indicated and decimal number systems.



2.47. Find the arithmetic mean of the following numbers:

2.48. The sum of octal numbers 17 8 + 1700 8 + 170000 3 + 17000000 8 +
+ 1700000000 8 was converted to hexadecimal number system.
Find in the entry a number equal to this amount, the fifth digit from the left.


Restore the unknown numbers marked with a question mark in
the following addition and subtraction examples, first defining
le, in what system the numbers are shown.

Lesson topic: Arithmetic operations in positional number systems.

Grade 9

Lesson objectives:

    Didactic: to acquaint students with addition, subtraction, multiplication and division in the binary system and to conduct a primary practice of the skill of carrying out these actions.

    Educational: to develop students' interest in learning new things, to show the possibility of a non-standard approach to calculations.

    Developing: develop attention, rigor of thinking, the ability to reason.

Lesson structure.

    Orgmoment -1 minute.

    Checking homework with an oral test -15 minutes.

    Homework -2 minutes.

    Solving problems with simultaneous analysis and independent development of the material -25 min.

    Summing up the lesson -2 minutes.

DURING THE CLASSES

    Organizational moment.

    Checking homework (oral test) .

The teacher reads the questions in sequence. Students listen carefully to the question without writing it down. Only the answer is recorded, and very briefly. (If it is possible to answer with one word, then only this word is recorded).

    What is a number system? (-this is a sign system in which numbers are written according to certain rules using the characters of some alphabet called numbers )

    What number systems do you know?( non-positional and positional )

    What system is called non-positional? (SCH is called non-positional if the quantitative equivalent (quantitative value) of a digit in a number does not depend on its position in the notation of the number ).

    What is the base of the positional SSC. (equal to the number of digits that make up its alphabet )

    What mathematical operation should be used to convert an integer from a decimal NSC to any other? (division )

    What needs to be done to convert a number from decimal to binary? (Consistently divide by 2 )

    How many times will the number 11.1 decrease 2 when moving the comma one character to the left? (2 times )

Now let's listen to a verse about an extraordinary girl and answer questions. (Sounds like a verse )

EXTRAORDINARY GIRL

She was a thousand and a hundred years old
She went to the one hundred and first class,
I carried a hundred books in my portfolio.
All this is true, not nonsense.

When, dusting with a dozen feet,
She walked along the road.
She was always followed by a puppy
With one tail, but hundred-legged.

She caught every sound
With ten ears
And ten tanned hands
They held a briefcase and a leash.

And ten dark blue eyes
Considered the world habitually,
But everything will become quite normal,
When you understand my story.

/ N. Starikov /

And how old was the girl? (12 years old ) What class did she go to? (5th grade ) How many arms and legs did she have? (2 arms, 2 legs ) How does a puppy have 100 legs? (4 paws )

After completing the test, the answers are pronounced aloud by the students themselves, a self-examination is carried out and the students give themselves marks.

Criterion:

    10 correct answers (maybe a small flaw) - “5”;

    9 or 8 - “4”;

    7, 6 – “3”;

    the rest are “2”.

II. Homework (2 minutes)

10111 2 - 1011 2 = ? ( 1100 2 )
10111 2 + 1011 2 = ? ( 100010 2 )
10111 2 * 1011 2 = ? ( 11111101 2 ))

III. Working with new material

Arithmetic operations in the binary 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:

0

1

1

1

Addition.

The binary addition table is extremely simple. Only in one case, when addition 1 + 1 is performed, does a transfer to the most significant bit occur.

1001 + 1010 = 10011

1101 + 1011 = 11000

11111 + 1 = 100000

1010011,111 + 11001,11 = 1101101,101

10111 2 + 1001 2 = ? (100000 2 )

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. 10111001,1 – 10001101,1 = 101100,0

101011111 – 110101101 = – 1001110

100000 2 - 10111 2 = ? (1001 2 )

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. 11001 * 1101 = 101000101

11001,01 * 11,01 = 1010010,0001

Multiplication is reduced to shifts of the multiplicand and additions.

111 2 * 11 2 = ? (10101 2 )

V. Summing up the lesson

Card for additional work of students.

Perform arithmetic operations:

A) 1110 2 + 1001 2 = ? (10111 2 ); 1101 2 + 110 2 = ? (10011 2 );

10101 2 + 1101 2 = ? (100010 2 ); 1011 2 + 101 2 = ? (10000 2 );

101 2 + 11 2 = ? (1000 2 ); 1101 2 + 111 2 = ? (10100 2 );

B) 1110 2 - 1001 2 = ? (101); 10011 2 - 101 2 = ? (1110 2 );

Addition. The addition of numbers in the binary number system is based on the addition table of single-digit binary numbers (Table 6).

It is important to pay attention to the fact that when adding two units, a transfer is made to the highest digit. This happens when the value of a number becomes equal to or greater than the base of the number system.

The addition of multi-digit binary numbers is performed in accordance with the above addition table, taking into account possible transfers from lower digits to higher digits. As an example, let's add binary numbers in a column:

Let's check the correctness of calculations by addition in the decimal number system. Let's convert the binary numbers to the decimal number system and add them:

Subtraction. The subtraction of binary numbers is based on the table of subtraction of single-digit binary numbers (Table 7).

When subtracting from a smaller number (0) a larger one (1), a loan is made from the highest order. In the table, the loan is indicated by 1 with a bar.

The subtraction of multi-digit binary numbers is implemented in accordance with this table, taking into account possible loans in high-order digits.

For example, let's subtract binary numbers:

Multiplication. Multiplication is based on the multiplication table of single-digit binary numbers (Table 8).

Multiplication of multi-digit binary numbers is carried out in accordance with this 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. Consider an example of binary multiplication

Read also: