Formats for representing data in computer logic codes. Representation of data in computer memory. Organization of RAM

LECTURE No. 1 “The concept of information, general characteristics processes of collection, transmission, processing and accumulation of information"

Information. Types of existence of information. Properties of information. Presentation of data in a computer. Notation. Positional number systems. Converting numbers from one number system to another. Encoding information. Units of information measurement. Transfer of information. Data processing. Data storage. Magnetic memory. Optical memory.

Information

Term "information" comes from the Latin word "information", which means information, explanation, presentation. Despite the widespread use of this term, the concept of information is one of the most controversial in science. Currently, science is trying to find general properties and patterns inherent in the multifaceted concept information, but for now this concept largely remains intuitive and receives different semantic content in various branches of human activity.

In everyday life, for example , information is any data or information that interests someone. "Inform" in this sense it means "to communicate something,previously unknown".

The modern scientific idea of ​​information was very precisely formulated by Norbert Wiener, the “father” of cybernetics. Namely: Information is the designation of content received from the external world in the process of our adaptation to it and the adaptation of our senses to it.

People exchange information in the form of messages. A message is a form of presenting information in the form of speech, texts, gestures, glances, images, digital data, graphs, tables, etc.

In cases where they say about automated work with information through any technical devices, Typically, people are primarily interested not in the content of the message, but in how many characters the message contains.

In relation to computer data processing, information is understood as a certain sequence of symbolic designations (letters, numbers, encoded graphic images and sounds, etc.), carrying a semantic load and presented in a form understandable to the computer. Each new character in such a sequence of characters increases the information volume of the message.



Types of existence of information

Information can exist in the form of:

Texts, drawings, drawings, photographs;

Light or sound signals;

Radio waves;

Electrical and nerve impulses;

Magnetic records; etc.

Objects, processes, phenomena of material or intangible properties, considered from the point of view of their information properties, are called information objects.

Information can be:

All these processes associated with certain operations on information are called information processes.

Information properties

Information is reliable if it reflects the true state of affairs. Inaccurate information can lead to misunderstandings or poor decisions.

Reliable information may become unreliable over time, since it tends to become outdated, that is, it ceases to reflect the true state of affairs.

The information is complete, if it is sufficient for understanding and decision-making. Both incomplete and redundant information hinder decision making or may lead to errors.

Accuracy of information is determined by the degree of its proximity to the real state of the object, process, phenomenon, etc.

The value of information depends on how important it is for solving the problem, as well as on how much further it will be used in any type of human activity.

Only timely information received may bring the expected benefits. Both premature presentation of information (when it cannot yet be assimilated) and its delay are equally undesirable.

If valuable and timely information is expressed in an unclear way, it can become useless.

Information becomes clear, if it is expressed in the language spoken by those for whom this information is intended.

Information must be presented in an accessible way(according to the level of perception) form. Therefore, the same questions are presented differently in school textbooks and scientific publications.

Information on the same issue can be summarized(concisely, without unimportant details) or extensively(detailed, verbose). Conciseness of information is necessary in reference books, encyclopedias, textbooks, and all kinds of instructions.

Presentation of data in a computer

All information in a computer is stored in the form of sets of bits, that is, combinations of 0 and 1. Numbers are represented as binary combinations in accordance with the number formats adopted for working in a given computer, and character code matches letters and other symbols to binary combinations.

There are three number formats for numbers:

Binary fixed point;

Binary floating point;

Binary Coded Decimal (BCD).

Floating point numbers are processed on a special coprocessor (FPU - floating point unit), which, starting with MP I486, is part of the microprocessor LSI. The data in it is stored in 80-bit registers.

Notation.

The method of representing images of arbitrary numbers using a certain finite set of symbols will be called a number system.

In everyday practice, we usually use the decimal number system.

Number systems are usually divided into...

1. Positional.

2. Non-positional.

3. Symbolic.

Symbolic. In these systems, each number is associated with its own symbol. These systems are not widely used due to their natural limitations (alchemy, coded messages) - the countless number of symbols that are required to represent all possible numbers. Therefore, we will omit these systems from consideration.

Topic 1. Principles of computer organization

Coding information in a computer.

Coding is the representation of characters from one alphabet by means of another alphabet.

A quantity capable of taking only two different values ​​is called bit.

How to represent characters from another alphabet using the binary alphabet?

To encode alphabets containing more than 2 characters, sequences of binary alphabet characters are used. For example, a sequence of two binary characters can encode 4 characters of another alphabet:

00 --> A 01 à B 10 à C 11 à D .

It can be shown that the number of possible combinations when using the binary alphabet is 2n, where n is the number of binary characters in the sequence. With n equal to 8, the number of possible combinations is 256, which is quite enough to encode most known alphabets, so a sequence of eight binary characters is widely used to encode information in computers. A sequence of eight binary digits is usually called byte.

Coding example:

symbol A à 1100 0001 symbol 9 à 1111 1001.

Currently, sequences of 16 binary characters (2 bytes) are also used to encode characters.

The technical carrier of information in a computer is a memory cell, consisting of a set of simple elements, each of which can be in one of two possible states (denoted as 0 and 1). A memory cell can contain a different number of simple elements. Typically the number of elements in a cell is a multiple of 8.

Larger units are also used to measure memory:

1 kilobyte (kb) = 2 10 bytes = 1024 bytes;

1 megabyte (MB) = 2 20 bytes = 1048576 bytes;

1 gigabyte (gb) = 2 30 bytes =

Machine code (or simply code) is the collection of 0s and 1s that a memory cell can store.

A code that is 2 bytes long is called a halfword.

a code 4 bytes long is called a word,

A code that is 8 bytes long is called a double word.

Computer architecture

At all times, man has sought to expand his capabilities by creating various devices (tools, knowledge of the world). For example, he compensated for his lack of vision with a microscope and telescope. The limited ability to transmit information to each other is expanded with the help of telephone, radio and television.

Computers (computers) “complement” the capabilities human brain information processing and allow you to increase the speed of calculations, and therefore decision-making during execution various works hundreds and thousands of times.

Man has always had to do calculations, so people sought to expand their capabilities for processing information, and primarily in the field of calculations. For this purpose, abacus, adding machine, etc. were invented. However, all these devices did not allow automated calculations.

Idea of ​​use program control for the construction of an automatic computing device was first proposed by the English mathematician Charles Babbage back in 1833. However, the low level of development of science and technology did not allow the creation of an automatic computing device at that time. The idea of ​​program control was further developed in the works of the American scientist John von Neumann.

In the 40s of the 20th century, work in the field of nuclear physics, ballistics, aerodynamics, etc. required enormous computational work. Science and technology were faced with a dilemma: either everyone should sit down with adding machines, or make a new effective automatic tool for calculations. It was at this time that J. von Neumann formulated the basic principles of constructing a computer. As a result, the first computer was built in 1945, and in 1953 mass production of computers began.

The computer architecture proposed by Neumann is shown in Fig. 1.1.1. The computer contains:

Input Devices(for example, a keyboard) for entering programs and data into a computer;

- Output devices(for example, monitor, printer, etc.) to output data from the computer;

- memory- a device for storing information. Memory can be built on various physical principles, but in any case it is a collection of cells in which various data (numbers, symbols) can be stored in encoded form. All memory cells are numbered. The memory cell number is called an address.

- CPU is a device capable of performing a certain set of operations on data and generating the values ​​of a given set of logical conditions on this data. The processor consists of a control unit (CU) and an arithmetic logical device(ALU).

The control unit is designed to execute commands and control the operation of the computer when executing a separate command.

The ALU is designed to perform arithmetic and logical operations, the set of which is determined by the command system adopted for of this type COMPUTER.

Program is an algorithm for solving a problem, presented in the form of an understandable computer.

The computer is based on two fundamental principles J. von Neumann.

1 Principle of stored program. According to this principle, a program coded in digital form stored in computer memory along with numbers (data). The commands do not indicate the numbers themselves involved in the operations, but the addresses of the memory cells in which they are located.

Example command

KO A1 A2 A3

where KO is the operation code; A1 – address of the first operand; A2 – address of the second operand; A3 is the address of the memory cell in which the result should be placed. KO, A1, A2, A3 are sequences of zeros and ones. For example

A1: 00011110……110001 (32 bits).

If KO is an addition operation code, then the meaning of this command can be formulated as follows:

Take the data from the cell with address A1;

Take the data from the cell with address A2;

Perform the addition operation of this data;

Place the result in cell with address A3.

Note that the commands do not indicate the data being processed, but the addresses of memory cells. All this makes the computer a universal means of information processing. To solve another problem, you do not need to change the equipment. It is enough to enter another program and data into memory.

2. The principle of random access to main memory. According to this principle, any memory cell is available to the processor at any time.

Operating principle of a computer

In accordance with these principles, the computer solves the problem in the following way.

1. The program in the form of a sequence of commands in encoded form (machine program) is located in the computer memory.

2. All data that the program uses is also located in memory.

3. The processor reads the next command from memory, the control unit deciphers it and determines who should execute it (ICU, ALU,). If this is an arithmetic type command, then control is transferred to the ALU, which determines what operation and on what data should be performed. The ALU then retrieves the data values ​​from memory and performs the specified operation. After transferring the result to memory, the ALU tells the control unit that the next instruction can be executed.

Almost all currently produced computers have Neumann architecture (the structure of the computer may be different).

Presentation of data in a computer.

The machine code of the processed information (data) is called operand. According to their semantic content, operands are divided into symbolic and numeric.

Character operands.

Character operands are sequences of characters from the original alphabet (letters, numbers, signs). To store each character, a memory cell of 1 byte is allocated, into which the character code is entered.

For example A (rus): 11100001: A (lat) 01000001.

Numeric data.

Presentation of data in a computer.

As a rule, the basis for presenting data in a computer is binary number system. Like decimal system number system, the binary system (which uses only the numbers 0 or 1) is a positional number system, i.e. in it, the meaning of each digit of a number depends on the position (position) of this digit in the notation of the number. Each position is assigned a certain weight.

IN computer technology The following positional number systems are also widely used: octal, hexadecimal and binary-decimal systems.

(In a nutshell - the 16th number system is a simple solution to a complex problem - the accurate representation of data in a computer, the 16th number system is a short notation for the binary system).

File formats

The main purpose of files is to store information. They are also designed to transfer data from program to program and from system to system. In other words, a file is a storage of stable and mobile data. But a file is more than just a data storage. Typically the file has name, attributes, modification time and creation time. The concept of a file has changed over time. The operating systems of the first mainframe computers thought of a file as storage for a database, and therefore a file was a collection of records. Typically, all entries in a file were the same size, often 80 characters each. At the same time, a lot of time was spent searching and writing data to a large file. At the end of the 60s, there was a trend towards simplifying operating systems, which made it possible to use them on less powerful computers. This was reflected in the development of the operating room Unix systems. In Unix, a file meant byte sequence. It became easier to store data on disk, since there was no need to remember the record size. Unix had a very large influence on other operating systems personal computers. Almost all of them support the Unix idea that a file is just a sequence of bytes. Files representing a stream of data began to be used when exchanging information between computer systems. If more than complex structure file (as in operating systems OS/2 and Macintosh), it can always be converted into a stream of bytes, transmitted and recreated in its original form at the other end of the communication channel.

File structure is a system for storing files on a storage device, such as a disk. Files are organized into directories (sometimes called directories or folders). Any directory can contain an arbitrary number of subdirectories, each of which can store files and other directories. The way data is organized into bytes is called file format. To read a file, for example, spreadsheet, you need to know how the bytes represent the numbers (formulas, text) in each cell; to read the file text editor, you need to know which bytes represent characters and which fonts or fields, as well as other information. Programs can store data in a file in any way the programmer chooses. It is often assumed, however, that the files will be used by different programs. For this reason, many application programs support some of the most common formats so that other programs can understand the data in the file. Manufacturing companies software(who want their programs to become "standards") often publish information regarding the formats they have created so that they can be used in other applications. All files can be divided into two parts - text and binary.

Text files- the most common data type in everything computer world. One byte is most often allocated to store each character, and text files are encoded using special tables in which each character corresponds to a certain number not exceeding 255. A file for which only the first 127 numbers are used for encoding is called ASCII file(short for American Standard Code for Information Interchange - American standard code for information exchange), but such a file cannot contain letters other than Latin (including Russian). Most national alphabets can be encoded using an eight-bit table. For the Russian language the most popular are this moment three encodings: Koi8-R, Windows-1251 and the so-called alternative (alt) encoding. More information about encoding Russian text is described in the chapter “Document Processing”. Languages ​​such as Chinese contain significantly more than 256 characters, so they use several bytes to encode each character. A common technique used to save space is to encode some characters using one byte, while others use two or more bytes. One of the attempts to generalize this approach is the standard Unicode, which uses the range of numbers from zero to 65,536 to encode characters. wide range allows you to represent in numerical form the symbols of the language of people from any corner of the planet. But pure text files are becoming increasingly rare. People want documents to contain pictures and diagrams and use a variety of fonts. As a result, formats appear that are various combinations of text, graphics and other forms of data.

Binary files, unlike text files, are not so easy to view and they usually do not contain words familiar to us - only a lot of incomprehensible symbols. These files are not intended to be directly read by humans. Examples of binary files are executable programs and files with graphic images.

Encoding numbers

There are two main formats for representing numbers in computer memory. One of them is used to encode integers, the second (the so-called floating-point representation of a number) is used to specify a certain subset of real numbers. A bunch of integers, representable in computer memory, is limited. The range of values ​​depends on the size of the memory area used to store the numbers. A k-bit cell can store 2 k different integer values. To obtain the internal representation of a positive integer N stored in a k-bit machine word, you need to:

    convert the number N to the binary number system;

    the resulting result is supplemented on the left with insignificant zeros up to k digits.

Example. Get the internal representation of the integer 1607 in a 2-byte cell.

Let's convert the number to the binary system: 1607 10 = 11001000111 2. The internal representation of this number in a cell will be: 0000 0110 0100 0111.

To record the internal representation of the whole negative number(-N) required:

    obtain an internal representation of a positive number N;

    reverse code of this number by replacing 0 with 1 and 1 with 0;

    add 1 to the resulting number.

Example. Let's get the internal representation of the negative integer -1607. Let's use the result of the previous example and write the internal representation of the positive number 1607: 0000 0110 0100 0111. By inverting we get the reverse code: 1111 1001 1011 1000. Let's add one: 1111 1001 1011 1001 - this is the internal binary representation of the number -1607.

Floating point format uses representation real number R in the form of the product of the mantissa m by the base of the number system n to some integer power p, which is called the order: R = m * n p.

Representing a number in floating point form is ambiguous. For example, the following equalities are true:

12.345 = 0.0012345 x 10 4 = 1234.5 x 10 -2 = 0.12345 x 10 2

Most often, computers use a normalized representation of a number in floating-point form. The mantissa in this representation must satisfy the condition: 0.1 p<= m < 1p. Иначе говоря, мантисса меньше 1 и первая значащая цифра - не ноль (p - основание системы счисления).

In computer memory, the mantissa is represented as an integer containing only significant digits (0 integers and a comma are not stored), so for the number 12.345, the number 12345 will be stored in the memory cell allocated for storing the mantissa. To unambiguously restore the original number, it remains only to preserve its order , in this example it is 2.

Text encoding

The set of characters used to write text is called alphabet. The number of characters in the alphabet is called its power.

To represent text information in a computer, an alphabet with a capacity of 256 characters is most often used. One character from such an alphabet carries 8 bits of information, since 2 8 = 256. But 8 bits make up one byte, therefore, the binary code of each character takes up 1 byte of computer memory.

All characters of such an alphabet are numbered from 0 to 255, and each number corresponds to an 8-bit binary code from 00000000 to 11111111. This code is the serial number of the character in the binary number system.

For different types of computers and operating systems, different encoding tables are used, differing in the order in which the alphabet characters are placed in the encoding table. The international standard on personal computers is the already mentioned ASCII encoding table.

The principle of sequential alphabet coding is that in the ASCII code table, Latin letters (uppercase and lowercase) are arranged in alphabetical order. The arrangement of numbers is also ordered by increasing values.

Only the first 128 characters are standard in this table, that is, characters with numbers from zero (binary code 00000000) to 127 (01111111). This includes letters of the Latin alphabet, numbers, punctuation marks, parentheses and some other symbols. The remaining 128 codes, starting with 128 (binary code 10000000) and ending with 255 (11111111), are used to encode letters of national alphabets, pseudographics characters and scientific symbols. Encoding of characters of the Russian alphabet is described in the chapter "Document Processing".

Encoding graphic information

IN video memory contains binary information about the image displayed on the screen. Almost all images created, processed or viewed using a computer can be divided into two large parts - raster and vector graphics.

Raster images are a single-layer grid of points called pixels (pixel, from the English picture element). Pixel code contains information about its color. For a black-and-white image (without halftones), a pixel can take only two values: white and black (lit or not lit), and to encode it, one bit of memory is enough: 1 - white, 0 - black. A pixel on a color display can have different colors, so one bit per pixel is not enough. Encoding a 4-color image requires two bits per pixel because two bits can take on 4 different states. For example, the following color coding option can be used: 00 - black, 10 - green, 01 - red, 11 - brown.

On RGB monitors, all the variety of colors is obtained by a combination of basic colors - red (Red), green (Green), blue (Blue), from which 8 basic combinations can be obtained:

color

color

brown

Of course, if you have the ability to control the intensity (brightness) of the glow of basic colors, then the number of different options for their combinations, generating various shades, increases. The number of different colors - K and the number of bits for encoding them - N are related to each other by a simple formula: 2 N = K.

In contrast to raster graphics, a vector image has many layers. Each element of a vector image - a line, a rectangle, a circle or a piece of text - is located in its own layer, the pixels of which are set independently of other layers. Each element of a vector image is an object that is described using a special language (mathematical equations of lines, arcs, circles, etc.). Complex objects (broken lines, various geometric shapes) are represented as a set of elementary graphic objects.

Vector image objects, unlike raster graphics, can change their size without loss of quality (when the raster image is enlarged, the graininess increases). More information about graphic formats is described in the "Graphics on a Computer" section.

Audio coding

From your physics course you know that sound- These are air vibrations. If we convert sound into an electrical signal (for example, using a microphone), we will see the voltage changing smoothly over time. For computer processing, such an analog signal must somehow be converted into a sequence of binary numbers.

Let's proceed as follows. We will measure the voltage at regular intervals and record the resulting values ​​in the computer memory. This process is called sampling(or digitization), and the device that performs it is analog-to-digital converter(ADC).

In order to reproduce the sound encoded in this way, you need to perform the inverse conversion (a digital-to-analog converter - DAC is used for this), and then smooth the resulting step signal.

The higher the sampling rate (that is, the number of samples per second) and the more bits allocated for each sample, the more accurately the sound will be represented. But this also increases the size of the sound file. Therefore, depending on the nature of the sound, the requirements for its quality and the amount of memory occupied, some compromise values ​​are chosen.

The described method of encoding sound information is quite universal; it allows you to represent any sound and transform it in a variety of ways. But there are times when it is more profitable to act differently.

Man has long used a fairly compact way of representing music - musical notation. It uses special symbols to indicate what pitch the sound is, what instrument to play and how to play it. In fact, it can be considered an algorithm for a musician, written in a special formal language. In 1983, leading computer and music synthesizer manufacturers developed a standard that defined such a code system. It was called MIDI.

Of course, such a coding system does not allow you to record every sound; it is only suitable for instrumental music. But it also has undeniable advantages: extremely compact recording, naturalness for the musician (almost any MIDI editor allows you to work with music in the form of ordinary notes), ease of changing instruments, changing the tempo and key of the melody.

Note that there are other, purely computer, formats for recording music. Among them, noteworthy is the MP3 format, which allows you to encode music with very high quality and compression ratio. At the same time, instead of 18-20 musical compositions, about 200 are placed on a standard CD (CDROM). One song takes up approximately 3.5 Mb, which allows Internet users to easily exchange musical compositions.

Data types

The main data types in computing are: bit, byte and word. Computers work primarily with bytes, which are the basic operating unit of computer data. Machine word(word) a technical term meaning 16 bits or 2 bytes at a time. Double word – 4 bytes, extended word – 8 bytes.

MSB (15) Bit LSB (0)

1 1 1 0 1 0 1 1 0 1 0 1 0 1 0 1

Byte Byte

There are three main formats for presenting data:

    binary fixed point;

    binary floating point;

    binary coded decimal (BCD).

If you need to encode a signed integer, then the most significant bit of the register (memory cell) is used to store the sign (0 for a positive sign of the number and 1 for a negative sign) - fixed point format.

Number sign 1 0 0 0 1 1 0 0 0 0 1 0 0 0 1

Number digits

The original capabilities of the computer allow it to work only with integers, and not the largest ones at that. Even in the case of a 2-byte word, we can write the maximum number 65536, taking into account the need to display both positive and negative numbers, we get only half of all numeric values. Methods of representing numbers and software can significantly expand the capabilities of a computer. To encode real numbers, 80-bit encoding is used. In this case, the number is first converted into a normalized form:

3,1415926 = 0,31415926 * 10 1

500 000 = 0,5 * 10 6

123 456 789 = 0,1 * 10 10

The first part of the number is called the mantissa - M, and the second one is of order q

In order to operate with fractional numbers or numbers of very large length, the concept is used floating point. Floating point operates on the principle of exponential format - numbers of the form -- -- - - + M *q + p

Number sign (mantissa)

Order sign Module Module

order mantissas

It should be noted that calculations with integers are performed very quickly, while calculations with floating point are hundreds of times slower.

To implement high-speed floating point calculations, numerical coprocessors (FPU - floating point unit) are used. The data in it is stored in 80-bit registers.

In binary-coded decimal format, each decimal digit is represented as a 4-bit binary equivalent. There are two main varieties of this format: packaged and unpackaged. In the packed BCD format, a string of decimal digits is stored as a sequence of 4 bit groups. In the unpacked format, each decimal digit is in the least significant tetrad of the byte, and the contents of the most significant tetrad are determined by the specific encoding system used by the computer, and in this case is not significant.

In addition, data comes in the form of strings - a continuous sequence of bits or bytes, character data supported by ASCII code, and pointer data. We will get to know them in more detail after studying computer architecture.

conclusions

Knowledge of the basic principles of computer operation is necessary for those engineers who have connected their careers with computer technology and telecommunications networks.

Despite the enormous progress in computer technology, the fundamental principles of how a computer functions as a tool for storing, processing and transmitting information have not changed.

Information cannot exist outside the interaction of objects and it is not lost by any of them in the process of interaction.

Information eliminates uncertainty, reduces chaos and entropy of the system.

All processes in nature are accompanied signals. The recorded signals form data. Formatted data – messages are transformed, transported and consumed using methods. With the interaction of data and methods adequate to them, a information. Information is a dynamic object formed during information process. The information process consists of: collection, storage, processing and transmission of information. To make it easier to work with data, they are structured.

The following important structures exist: linear, tabular and hierarchical. Computers use a universal coding system called binary code. The elementary unit of data representation is called - bit, next come byte, word, double word.

Questions and tasks

    How do you understand the term “mass media”? What is this?

    Is data a commodity? Can methods be a commodity?

    Determine which message contains more information:

    The dog bit the boy;

    The boy bit the dog.

    What happens to the information at the end of the information process?

    List the main components of the information process.

    What is a positional number system? Give examples of such systems.

    What number is the base of the decimal, binary number system?

    Convert a number from one number system to another:

    2 10 = X 2, 1011 2 = X 10, 16 10 = X 2, 1011.1 2 = X 10

    Write the binary number corresponding to the decimal number 5 in one-byte format.

Another example is the family of computers developed under the leadership of Israel Yakovlevich Akushsky (1911–1992). To speed up a number of arithmetic operations, he proposed using not a positional (traditional binary, or ternary, like Brusentsov), but an original system of calculations in residual classes (RNC). Work on computers at SOK began in 1957 at SKB-245, then continued in other organizations. At a time when the speed of traditional computers was measured in tens of thousands of op./s, the performance of computers in RNS on a certain class of tasks reached a million op./s. Akushsky's vehicles were successfully used in the interests of the country's air defense.

To represent information in computer memory (both numeric and non-numeric), a binary coding method is used. An elementary computer memory cell is 8 bits (bytes) long. Each byte has its own number (it is called an address). The largest sequence of bits that a computer can process as a single unit is called a machine word. The length of a machine word depends on the processor bit depth and can be 16, 32 bits, etc. One byte is enough to encode characters. In this case, 256 characters can be represented (with decimal codes from 0 to 255). The IBM PC character set is most often an extension of the ASCII code (American Standard Code for Information Interchange). In some cases, when representing numbers in computer memory, a mixed binary-decimal “number system” is used, where each decimal place requires a nibble (4 bits) and the decimal digits from 0 to 9 are represented by the corresponding binary numbers from 0000 to 1001. For example, packed The decimal format, designed to store integers with 18 significant digits and occupying 10 bytes in memory (the most significant of which is signed), uses this particular option. Another way to represent integers is with two's complement code. The range of value values ​​depends on the number of memory bits allocated for their storage. For example, values ​​of type Integer (all data type names here and below are presented in the form in which they are accepted in the Turbo Pascal programming language; other languages ​​also have such data types, but may have different names) lie in the range from -32768 ( -2 15) to 32767 (2 15 - 1), and 2 bytes are allocated to store them; type Longlnt - in the range from -2 31 to 2 31 - 1 and are located in 4 bytes; Word type - in the range from 0 to 65535 (2 16 - 1) (2 bytes are used), etc. As can be seen from the examples, the data can be interpreted as signed or unsigned numbers. When representing a signed quantity, the leftmost (most significant) digit indicates a positive number if it contains a zero, and a negative number if it contains a one. In general, bits are numbered from right to left, starting from 0. The numbering of bits in a two-byte machine word is shown below. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 The complementary code of a positive number is the same as its direct code. The direct code of an integer can be obtained as follows: the number is converted to the binary number system, and then its binary notation on the left is supplemented with as many insignificant zeros as required by the data type to which the number belongs. For example, if the number 37 (10) = 100101 (2) is declared as a value of type Integer, then its direct code will be 0000000000100101, and if it is a value of type LongInt, then its direct code will be. For a more compact notation, hexadecimal code is often used. The resulting codes can be rewritten respectively as 0025 (16) and 00000025 (16). The complementary code of a negative integer can be obtained using the following algorithm: 1) write down the direct code of the modulus of the number; 2) invert it (replace ones with zeros, zeros with ones); 3) add one to the inverse code. For example, let's write down the additional code of the number (-37), interpreting it as a LongInt type value: 1) there is a direct code for the number 37; 2) inverse code; 3) additional code or FFFFFFDB (16). When obtaining a number from its complement code, first of all it is necessary to determine its sign. If the number turns out to be positive, then simply convert its code to the decimal number system. In the case of a negative number, it is necessary to perform the following algorithm: 1) subtract 1 from the number code; 2) invert the code; 3) convert to the decimal number system. Write the resulting number with a minus sign. Examples. Let's write down the numbers corresponding to the additional codes: a) 0000000000010111. Since zero is written in the most significant digit, the result will be positive. This is the code for the number 23; b) 1111111111000000. The code for a negative number is written here. We execute the algorithm: 1) 1111I11111000000 (2) - 1 (2)= 1111111110111111 (2) ; 2) 0000000001000000; 3) 1000000 (2) = 64 (10) . Answer: -64. A slightly different method is used to represent real numbers in the memory of a personal computer. Let's consider the representation of floating point values. Any real number can be written in standard form M10 p, where 1

The personal computer IBM PC allows you to work with the following real types (the range of values ​​is indicated in absolute value): Let us show the transformation of a real number to represent it in computer memory using the example of a value of type Double. As can be seen from the table, this type of value takes up 8 bytes in memory. The figure shows how the mantissa and order fields are represented here: You can notice that the most significant bit allocated for the mantissa is number 51, i.e. The mantissa occupies the lower 52 bits. The bar here indicates the position of the binary point. The comma must be preceded by a bit of the integer part of the mantissa, but since it is always equal to 1, this bit is not required here and the corresponding bit is not in memory (but it is implied). The order value, to simplify calculations and comparisons of real numbers, is stored as a biased number, i.e. An offset is added to the current order value before it is written to memory. The offset is chosen so that the minimum order value corresponds to zero. For example, for the Double type, the order takes up 11 bits and has a range from 2~1023 to 21023, so the offset is 1023(10) = 1111111111(2). Finally, bit number 63 indicates the sign of the number. Thus, from the above, the following algorithm follows for obtaining a representation of a real number in computer memory: 1) convert the modulus of a given number to the binary number system; 2) normalize the binary number, i.e. written in the form M-2 P, where M is the mantissa (its integer part is equal to 1 (2)) and p is the order written in the decimal number system; 3) add a shift to the order and convert the shifted order to the binary number system; 4) taking into account the sign of a given number (0 - positive; 1 - negative), write down its representation in the computer memory. Example. Let's write down the number code -312.3125. 1) The binary notation of the modulus of this number is 100111000.0101. 2) We have 100111000.0101 = 1.001110000101 2 8 . 3) We get the shifted order 8 + 1023 = 1031. Next we have 10000000111 (2) . . 4) Finally

1) First of all, we note that this is a code for a positive number, since the digit number 63 contains a zero. Let's get the order of this number: 01111111110 (2) = 1022 (10) ; 1022 - 1023 = -1. 2) The number looks like 1.1100011-2“ 1 or 0.11100011. 3) Converting to the decimal number system we get 0.88671875.

To represent information in computer memory (both numeric and non-numeric), a binary coding method is used.

An elementary computer memory cell is 8 bits (bytes) long. Each byte has its own number (it is called address). The largest sequence of bits that a computer can process as a single unit is called in machine words. The length of a machine word depends on the processor bit depth and can be 16, 32, 64 bits, etc.

BCD encoding

In some cases, when representing numbers in computer memory, a mixed binary-decimal “number system” is used, where each decimal place requires a nibble (4 bits) and the decimal digits from 0 to 9 are represented by the corresponding binary numbers from 0000 to 1001. For example, packed The decimal format, designed to store integers with 18 significant digits and occupying 10 bytes in memory (the most significant of which is signed), uses exactly this option.

Representing integers in two's complement

Another way to represent integers is additional code. The range of value values ​​depends on the number of memory bits allocated for their storage. For example, values ​​of type Integer (all data type names here and below are presented in the form in which they are accepted in the Turbo Pascal programming language. Other languages ​​also have such data types, but may have different names) lie in the range from -32768 ( -2 15) to 32767 (2 15 - 1) and 2 bytes (16 bits) are allocated for storing them; type LongInt - in the range from -2 31 to 2 31 - 1 and are located in 4 bytes (32 bits); Word type - in the range from 0 to 65535 (2 16 - 1) (2 bytes are used), etc.

As can be seen from the examples, the data can be interpreted as signed numbers, so unsigned. When representing a signed quantity, the leftmost (most significant) digit indicates a positive number if it contains a zero, and a negative number if it contains a one.

In general, bits are numbered from right to left, starting from 0. The numbering of bits in a two-byte machine word is shown below.

Additional code positive number coincides with its direct code. The direct code of an integer can be obtained as follows: the number is converted to the binary number system, and then its binary notation on the left is supplemented with as many insignificant zeros as required by the data type to which the number belongs.

For example, if the number 37 (10) = 100101 (2) is declared as a value of type Integer ( sixteen-bit signed), then its direct code will be 0000000000100101, and if the value is of type LongInt ( thirty-two-bit signed), then its direct code will be. For a more compact notation, hexadecimal representation of the code is often used. The resulting codes can be rewritten respectively as 0025 (16) and 00000025 (16).

A negative integer's complement can be obtained using the following algorithm:

  1. write down the direct code of the modulus of the number;
  2. invert it (replace ones with zeros, zeros with ones);
  3. add one to the inverse code.

For example, let's write down the additional code of the number -37, interpreting it as a LongInt value (signed thirty-two bits):

  1. there is a direct code for the number 37;
  2. inverse code;
  3. additional code or FFFFFFDB (16) .

When obtaining a number from its complement code, first of all it is necessary to determine its sign. If the number turns out to be positive, then simply convert its code to the decimal number system. In case of a negative number, the following algorithm must be performed.