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 min.

    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-bit 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

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, to which, in turn, one input signal is 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 logical 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, the recording of a new number will begin 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. Consistently 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 conversion 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 3. Consider each group as an n-bit binary number and write it 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 with the corresponding digit in the number system with base q \u003d 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 = 2p. 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.

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, 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.

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.

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 that 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 content 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.