The largest amount of information is about 90. Introduction to the subject of computer science

NUMERAL SYSTEMS

General information

Brief overview. Basic terms and concepts

A number system is a way of representing any number using an alphabet of symbols called digits.

There are many number systems that can be divided into 2 types: non-positional and positional.

Non-positional system. An example is the Roman numeral system. In it, the meaning of each symbol is constant, no matter where the symbol is in the number.

I, IX, XXI, LXI, XLII – the symbol “I” in all given numbers encodes the digit one.

Positional systems. An example is the Arabic system. In the positional system, the meaning of each digit (symbol) depends on the place in the number where this digit (symbol) is written. Let's verify this using an example from the decimal system we have adopted, by performing identical number transformations.

5555=5000+500+50+5. So, the number 5 stands for 5000, 500, 50 and 5.

The decimal system uses 10 digits (symbols) to write numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The number of digits (symbols) used in the system is called its base, therefore, in our system The base is 10, which is why it is called decimal. Let's do the decimal conversion again

5685=5*1000+6*100+8*10+5=5*10 3 +6*10 2 +8*10 1 +5*10 0

We see that the number can be written using terms in which the base of the system is present. It is raised to a power one less than the order of the digit in the number from right to left.

In addition to the decimal system, there are some other number systems. For example, 12-digit was used in Russia until 1917. The expressions “dozen” and “devil’s dozen” are still preserved. It is still used in the currencies of some countries. There are 12 numbers on the clock. 12 months a year, etc.

The ability to use different number systems is based on the fact that many different symbols can be written on a storage medium (paper, papyrus) and given some specific meaning.

Methods for recording information in computer technology

On storage media associated with computer technology, there are currently no broad opportunities for recording information. To record information in computer technology, two stable states of different devices are used.

On a floppy disk or hard drive, which can be imagined as consisting of a set of elementary magnets, these magnets can be turned with the north or south pole towards the substrate. A point on a disk may or may not reflect light. A card made of thick paper may or may not have a hole in a certain location. An electrical circuit may or may not conduct current. The light may or may not be on. One such state can be assigned the value 1, the second 0. Thus, either 0 or 1 can be written on one memory element.

This minimum amount of information that can be recorded on such media is called bit.

Historically, 8 storage media were combined into one memory cell, and the amount of information recorded in them was called byte. Thus 1 byte = 8 bits.
In a byte you can write 2 8 = 256 different combinations of binary numbers, that is, numbers consisting of only two digits 0 and 1: 00000000, 00000001, 00000010, 00000011. . . 11111110, 11111111.

If you look at several memory cells, they will contain many zeros and ones. Memory cell addresses are also represented in binary. To make it easier for a person to work with this kind of information, we decided to work with it according to the rules of the 2nd number system. The numbers of this system can be converted into other more familiar and visual systems for humans: 8-digit, 16-digit, 10-digit.

Table 1.1.2

Decimal system Binary system Octal system Hexadecimal system
A
B
C
D
E
F

Table 1.1.2 shows which symbols are used as numbers in different systems. If the last valid character is used, then 0 is written in the least significant digit, and 1 in the most significant one.

Arithmetic operations in number systems

The rules for performing arithmetic operations in the decimal number system are also preserved for other positional number systems.

Addition

We add the ones first, then the tens, etc. until we reach the highest rank. At the same time, we always remember that when, when adding numbers in any digit, a sum greater than the base is obtained, then we must carry it over to the next digit.

For example 173, 261 8

16, 35 8

Octal s.s.

LESSON No. 19-20.

Subject

Arithmetic operations in positional number systems. Multiplication and division.

Objective of the lesson: show methods of arithmetic operations (multiplication and division) of numbers in different number systems, test mastery of the topic “Adding and subtracting numbers in different number systems.”

Lesson objectives:

    educational: practical application of the studied material on the topic “Multiplication and division in various number systems”, consolidation and testing of knowledge on the topic “Adding and subtracting numbers in various number systems”. developing: development of individual practical work skills, the ability to apply knowledge to solve problems. educational: achieving conscious mastery of the material by students.

Materials and equipment for the lesson: cards for independent work, multiplication tables.

Lesson type: combined lesson

Lesson format: individual, frontal.

Lesson progress:

1. Checking homework.

Homework:

1. № 2.41 (1 and 2 columns), workshop, p. 55

Solution:

A) 11102+10012 =101112

B) 678+238=1128

B)AF16+9716 = 14616

D)11102-10012 =1012

D) 678-238 =448

E) AF16-9716 =1816

2. No. 2.48 (page 56)

2. Independent work “Adding and subtracting numbers in various number systems.” (20 minutes)

Independent work. 10th grade.

11 + 1110 ; 10111+111 ; 110111+101110

3. Subtract: 10111-111; 11 - 1110

4. Add and subtract in octal system: 738 and 258

Option 1

Independent work. 10th grade. Binary number system: translation 2® 10; addition.

1. Convert from the binary number system to the decimal number system.

2. Add two binary numbers.

1110+111 ; 111+1001 ; 1101+110001

3. Subtract: 111-1001; 1110+111

4. Add and subtract in hexadecimal: 7316 and 2916

Option 2

3. New material.


1. Multiplication

When multiplying multi-digit numbers in different positional number systems, you can use the usual algorithm for multiplying numbers in a column, but the results of multiplying and adding single-digit numbers must be borrowed from the multiplication and addition tables corresponding to the system in question.

Multiplication in binary system

Multiplication in octal system

Due to the extreme simplicity of the multiplication table in the binary system, multiplication is reduced only to shifts of the multiplicand and additions.

Example 1. Let's multiply the numbers 5 and 6 in decimal, binary, octal and hexadecimal number systems.

https://pandia.ru/text/80/244/images/image004_82.gif" width="419" height="86 src=">
Answer: 5 . 6 = 3010 = 111102 = 368.
Examination.
111102 = 24 + 23 + 22 + 21 = 30;
368 = 381 + 680 = 30.

Example 2. Let's multiply the numbers 115 and 51 in decimal, binary, octal and hexadecimal number systems.

https://pandia.ru/text/80/244/images/image006_67.gif" width="446" height="103 src=">
Answer: 115 . 51 = 586510 = 10110111010012 = 133518.
Examination. Let's convert the resulting products to decimal form:
10110111010012 = 212 + 210 + 29 + 27 + 26 + 25 + 23 + 20 = 5865;
133518 = 1 . 84 + 3 . 83 + 3 . 82 + 5 . 81 + 1 . 80 = 5865.

2. DIVISION

Division in any positional number system is carried out according to the same rules as division by angle in the decimal system. In the binary system, division is especially easy, because the next digit of the quotient can be only zero or one.
Example 3. Divide the number 30 by the number 6.

https://pandia.ru/text/80/244/images/image008_48.gif" width="478" height="87 src=">
Answer: 30: 6 = 510 = 1012 = 58.

Example 4. Divide the number 5865 by the number 115.

https://pandia.ru/text/80/244/images/image010_50.gif" width="400" height="159 src=">

Octal: 133518:1638

https://pandia.ru/text/80/244/images/image012_40.gif" width="416" height="18 src=">

https://pandia.ru/text/80/244/images/image014_36.gif" width="72" height="89 src=">
Answer: 35: 14 = 2,510 = 10,12 = 2,48.
Examination. Let's convert the resulting quotients to decimal form:
10,12 = 21 + 2 -1 = 2,5;
2,48 = 2 . 80 + 4 . 8-1 = 2,5.

4. Homework:

1. Prepare for test No. 2 “On the topic of Number systems. Translation of numbers. Arithmetic operations in number systems"

2. Workshop Ugrinovich, No. 2.46, 2.47, p. 56.

Literature:

1. Workshop on computer science and information technology. Textbook for educational institutions / , . – M.: Binom. Laboratory of Knowledge, 2002. 400 pp.: ill.

2. Ugrinovich and information technologies. Textbook for grades 10-11. – M.: BINOM. Knowledge Laboratory, 2003.

3. Shautsukova: Textbook. allowance for 10-11 grades. general education institutions. – M.: Education, 2003.9 - p. 97-101, 104-107.

Note:
You can perform actions only in one number system; if you are given different number systems, first convert all the numbers into one number system
If you are working with a number system whose base is greater than 10 and you have a letter in your example, mentally replace it with a number in the decimal system, carry out the necessary operations and convert the result back to the original number system

Addition:
Everyone remembers how in elementary school we were taught to add in a column, place by place. If, when adding in a digit, a number greater than 9 was obtained, we subtracted 10 from it, the resulting result was written down in the answer, and 1 was added to the next digit. From this we can formulate a rule:

  1. It’s more convenient to fold in a “column”
  2. Adding place by place, if the digit in the place > is greater than the largest digit of the alphabet of a given number system, we subtract the base of the number system from this number.
  3. We write the result in the required category
  4. Add one to the next digit
Example:

Add 1001001110 and 100111101 in binary number system

1001001110

100111101

1110001011

Answer: 1110001011

Add F3B and 5A in hexadecimal notation

FE0

Answer: FE0


Subtraction: Everyone remembers how in elementary school we were taught to subtract by column, place value from place value. If, when subtracting in a digit, a number less than 0 was obtained, then we “borrowed” one from the highest digit and added 10 to the desired digit, and subtracted the required one from the new number. From this we can formulate a rule:

  1. It is more convenient to subtract in a “column”
  2. Subtracting placewise if the digit is in place< 0, вычитаем из старшего разряда 1, а к нужному разряду прибавляем основание системы счисления.
  3. We perform subtraction
Example:

Subtract the number 100111101 from 1001001110 in binary number system

1001001110

100111101

100010001

Answer: 100010001

Subtract 5A from F3B in hexadecimal notation

D96

Answer: D96

Most importantly, do not forget that you only have numbers of a given number system at your disposal, and also do not forget about transitions between digit terms.
Multiplication:

Multiplication in other number systems occurs in exactly the same way as we are used to multiplying.

  1. It is more convenient to multiply in a “column”
  2. Multiplication in any number system follows the same rules as in the decimal system. But we can only use the alphabet given by the number system
Example:

Multiply 10111 by 1101 in binary number system

10111

1101

10111

10111

10111

100101011

Answer: 100101011

Multiply F3B by number A in hexadecimal notation

F3B

984E

Answer: 984E

Answer: 984E

Most importantly, do not forget that you only have numbers of a given number system at your disposal, and also do not forget about transitions between digit terms.

Division:

Division in other number systems occurs in exactly the same way as we are used to dividing.

  1. It is more convenient to divide in a “column”
  2. Division in any number system follows the same rules as in the decimal system. But we can only use the alphabet given by the number system

Example:

Divide 1011011 by 1101 in binary number system

Divide F 3 B for number 8 in hexadecimal number system

Most importantly, do not forget that you only have numbers of a given number system at your disposal, and also do not forget about transitions between digit terms.

NON-POSITIONAL

Non-positional number systems

Non-positional number systems appeared historically first. In these systems, the meaning of each digital character is constant and does not depend on its position. The simplest case of a non-positional system is the unit system, for which a single symbol is used to denote numbers, usually a bar, sometimes a dot, of which the quantity corresponding to the designated number is always placed:

  • 1 - |
  • 2 - ||
  • 3 - |||, etc.

So this one character has meaning units, from which the required number is obtained by successive addition:

||||| = 1+1+1+1+1 = 5.

A modification of the unit system is the system with a base, in which there are symbols not only to designate the unit, but also for the degrees of the base. For example, if the number 5 is taken as the base, then there will be additional symbols to indicate 5, 25, 125, and so on.

An example of such a base 10 system is the ancient Egyptian one, which arose in the second half of the third millennium BC. This system had the following hieroglyphs:

  • pole - units,
  • arc - tens,
  • palm leaf - hundreds,
  • lotus flower - thousands.

The numbers were obtained by simple addition; the order could be any. So, to designate, for example, the number 3815, three lotus flowers, eight palm leaves, one arc and five poles were drawn. More complex systems with additional signs - old Greek, Roman. The Roman one also uses an element of the positional system - a larger number in front of a smaller one is added, a smaller one in front of a larger one is subtracted: IV = 4, but VI = 6, this method, however, is used exclusively to denote the numbers 4, 9, 40, 90, 400 , 900, 4000, and their derivatives by addition.

The modern Greek and ancient Russian systems used 27 letters of the alphabet as numbers, where they denoted each number from 1 to 9, as well as tens and hundreds. This approach made it possible to write numbers from 1 to 999 without repeating numbers.

In the old Russian system, special frames around the numbers were used to indicate large numbers.

The non-positional numbering system is still used almost everywhere as a verbal numbering system. Verbal numbering systems are strongly tied to the language, and their common elements mainly relate to the general principles and names of large numbers (trillion and above). The general principles underlying modern verbal numberings involve the formation of designations through addition and multiplication of the meanings of unique names.

Arithmetic operations in all positional number systems are performed according to the same rules. To carry out arithmetic operations on numbers represented in different number systems, it is necessary to first convert them into one number system and take into account the fact that the transfer to the next digit during the addition operation and the loan from the highest digit during the subtraction operation are determined by the value of the base of the number system.

Arithmetic operations in the binary number system are based on tables for adding, subtracting and multiplying single-digit binary numbers.

When adding two units, the digit overflows and the unit is transferred to the highest digit; when subtracting 0–1, a loan is made from the highest digit; in the “Subtraction” table, this loan is designated 1 with a line over the number (Table 3).

Table 3

Below are examples of performing arithmetic operations on numbers represented in various number systems:

Arithmetic operations on integers represented in various number systems are quite simply implemented using the Calculator and MS Excel programs.

1.3. Representing numbers in a computer

Numerical data is processed in a computer using the binary number system. Numbers are stored in computer memory in binary code, that is, as a sequence of zeros and ones, and can be represented in fixed or floating point format.

Integers are stored in memory in fixed-point format. With this format for representing numbers, a memory register consisting of eight memory cells (8 bits) is allocated for storing non-negative integer numbers. Each digit of a memory cell always corresponds to the same digit of the number, and the comma is located to the right after the least significant digit and outside the bit grid. For example, the number 110011012 would be stored in a memory register as follows:

Table 4

The maximum value of a non-negative integer number that can be stored in a register in fixed-point format can be determined from the formula: 2n – 1, where n is the number of digits of the number. The maximum number will be equal to 28 - 1 = 25510 = 111111112 and the minimum 010 = 000000002. Thus, the range of changes in non-negative integers will be from 0 to 25510.

Unlike the decimal system, the binary number system in the computer representation of a binary number does not have symbols indicating the sign of the number: positive (+) or negative (-), therefore, to represent signed integers in the binary system, two number representation formats are used: number value format signed and two's complement format. In the first case, two memory registers (16 bits) are allocated for storing signed integers, and the most significant digit (leftmost) is used as the sign of the number: if the number is positive, then 0 is written to the sign bit, if the number is negative, then 1. For example , the number 53610 = 00000010000110002 will be represented in the memory registers in the following form:

Table 5

and a negative number -53610 = 10000010000110002 in the form:

Table 6

The maximum positive number or minimum negative number in signed number value format (taking into account the representation of one digit per sign) is 2n-1 – 1 = 216-1 – 1 = 215 – 1 = 3276710 = 1111111111111112 and the range of numbers will be from - 3276710 to 32767.

Most often, to represent signed integers in the binary system, the two's complement code format is used, which allows you to replace the arithmetic operation of subtraction in a computer with an addition operation, which significantly simplifies the structure of the microprocessor and increases its performance.

To represent negative integers in this format, two's complement code is used, which is the modulus of a negative number to zero. Converting a negative integer to two's complement is carried out using the following operations:

1) write the module of the number in direct code in n (n = 16) binary digits;

2) get the reverse code of the number (invert all digits of the number, i.e. replace all ones with zeros, and zeros with ones);

3) add one to the least significant digit to the resulting reverse code.

For example, for the number -53610 in this format, the modulus will be 00000010000110002, the reciprocal code will be 1111110111100111, and the additional code will be 1111110111101000.

It must be remembered that the complement of a positive number is the number itself.

To store signed integers other than the 16-bit computer representation when used two memory registers(this number format is also called the short signed integer format), the medium and long signed integer formats are used. To represent numbers in the mid number format, four registers are used (4 x 8 = 32 bits), and to represent numbers in the long number format, eight registers are used (8 x 8 = 64 bits). The ranges of values ​​for the medium and long number formats will be respectively: -(231 – 1) ... + 231 – 1 and -(263-1) ... + 263 – 1.

Computer representation of numbers in fixed point format has its advantages and disadvantages. TO benefits include the simplicity of representing numbers and algorithms for implementing arithmetic operations; the disadvantages are the finite range of representation of numbers, which may be insufficient for solving many problems of a practical nature (mathematical, economic, physical, etc.).

Real numbers (finite and infinite decimals) are processed and stored in a computer in floating point format. With this number representation format, the position of the decimal point in the entry may change. Any real number K in floating point format can be represented as:

where A is the mantissa of the number; h – base of the number system; p – number order.

Expression (2.7) for the decimal number system will take the form:

for binary -

for octal -

for hexadecimal -

This form of number representation is also called normal . With a change in order, the comma in the number shifts, that is, it seems to float to the left or to the right. Therefore, the normal form of representing numbers is called floating point form. The decimal number 15.5, for example, in floating point format can be represented as: 0.155 102; 1.55 101; 15.5 100; 155.0 10-1; 1550.0 · 10-2, etc. This form of decimal floating point notation 15.5 is not used when writing computer programs and entering them into a computer (computer input devices accept only linear data recording). Based on this, expression (2.7) for representing decimal numbers and entering them into the computer is converted to the form

where P is the order of number,

i.e., instead of the base of the number system 10, they write the letter E, instead of a comma, a dot, and the multiplication sign is not placed. Thus, the number 15.5 in floating point and linear format (computer representation) will be written as: 0.155E2; 1.55E1; 15.5E0; 155.0E-1; 1550.0E-2, etc.

Regardless of the number system, any number in floating point form can be represented by an infinite number of numbers. This form of recording is called non-normalized . For an unambiguous representation of floating point numbers, a normalized form of writing a number is used, in which the mantissa of the number must meet the condition

where |A| - the absolute value of the mantissa of the number.

Condition (2.9) means that the mantissa must be a proper fraction and have a non-zero digit after the decimal point, or, in other words, if the mantissa does not have a zero after the decimal point, then the number is called normalized. So, the number 15.5 in normalized form (normalized mantissa) in floating point form will look like this: 0.155 102, i.e. the normalized mantissa will be A = 0.155 and order P = 2, or in the computer representation of the number 0.155E2 .

Floating point numbers have a fixed format and occupy four (32 bits) or eight bytes (64 bits) of computer memory. If a number occupies 32 bits in the computer's memory, then it is a regular precision number; if it is 64 bits, then it is a double precision number. When writing a floating point number, bits are allocated to store the sign of the mantissa, sign of the exponent, mantissa and exponent. The number of digits allocated to the order of the number determines the range of variation of the numbers, and the number of digits allocated to store the mantissa determines the accuracy with which the number is specified.

When performing arithmetic operations (addition and subtraction) on numbers presented in floating point format, the following procedure (algorithm) is implemented:

1) the order of numbers on which arithmetic operations are performed is aligned (the order of a smaller absolute number increases to the order of a larger absolute number, while the mantissa decreases by the same amount);

2) arithmetic operations are performed on the mantissas of numbers;

3) the result obtained is normalized.