Contacts

Presentation of numbers in the computer. Format representation of a floating point numbers How negative numbers are stored in the computer's memory

Numeric data is processed in a computer in a binary number system. The numbers are stored in the computer's memory in binary code, i.e., in the form of a sequence of zeros and units, and can be represented in a fixed or floating semicolon format.

The integers are stored in memory in a fixed semicolon format. With this format of the representation of the numbers for storing integer non-negative numbers, a memory register is assigned consisting of eight memory cells (8 bits). Each category of memory cells always corresponds to the same number of numbers, and the comma is on the right after the youngest discharge and beyond the discharge mesh. For example, the number 110011012 will be stored in the memory register as follows:

Table 4.

The maximum value of an integer non-negative number, which can be stored in the register in a fixed-plated 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 \u003d 25510 \u003d 111111112 and the minimum 010 \u003d 000000002. Thus, the range of changes in integer non-negative numbers will be from 0 to 25510.

In contrast to the decimal system in a binary number system with a computer representation of a binary number, there are no symbols that indicate the number of numbers: positive (+) or negative (-), so for the representation of integers with a sign in the binary system, two numbers representation format are used: the number of number with the sign and format of the additional code. In the first case, two memory registers (16 bits) are allocated to store integers with a sign, and the older discharge (extreme left) is used under the number: if the number is positive, then 0 if the number is negative, then - 1. For example The number 53610 \u003d 00000010000110002 will be presented in memory registers as follows:

Table 5.

and the negative number is -53610 \u003d 10000010000110002 in the form:

Table 6.

Maximum positive number or minimal negative in the format of the value of the number with a sign (taking into account the view of one discharge under the sign) is 2N-1 - 1 \u003d 216-1 - 1 \u003d 215 - 1 \u003d 3276710 \u003d 1111111111111112 and the range of numbers will be within - 3276710 to 32767.

Most often to represent integers with a familiar binary system, an additional code format is applied, which allows you to replace the arithmetic operation of subtraction in the computer with an operation of addition, which significantly simplifies the structure of the microprocessor and increases its speed.

To represent entire negative numbers in such a format, an additional code is used, which is the addition of a negative number module to zero. The transfer of a whole negative number to the additional code is carried out using the following operations:


1) the module of the number to record direct code in n (n \u003d 16) binary discharges;

2) get the reverse code of the number (invert all the discharges of the number, i.e. all units are replaced by zeros, and zeros - by units);

3) To the resulting reverse code, add a unit to the younger category.

For example, for the number -53610 in such format, the module will be equal to 00000010000110002, the reverse code - 1111110111100111, and the additional code - 1111110111101000.

It must be remembered that the additional code of a positive number is the number.

To store integers with a sign in addition to a 16-bit computer representation when used two memory registers (Such a format of the number is also called a format of short integers with a sign), the formats of medium and long integers are applied with a sign. To represent numbers in the middle number format, four registers are used (4 x 8 \u003d 32 bits), and for the presentation of numbers in the format of long numbers - eight registers (8 x 8 \u003d 64 bits). Ranges of values \u200b\u200bfor the format of medium and long numbers will be respectively equal: - (231 - 1) ... + 231 - 1 and - (263-1) ... + 263 - 1.

The computer representation of the numbers in a fixed-comma format has its advantages and disadvantages. TO benefits The simplicity of the presentation of numbers and algorithms for the implementation of arithmetic operations, to disadvantages - the final range of numbers representation, which may be insufficient to solve many practical problems (mathematical, economic, physical, etc.).

The real numbers (final and infinite decimal fractions) are processed and stored in a floating-point compute. With this format of the representation of the number, the position of the comma in the record may vary. Any real number to a floating semicolon can be represented as:

where a is mantissa numbers; h is the base of the number system; P is the order of the number.

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

for binary -

for octal -

for hexadecimal -

This form representation is also called normal . With the change of order of the comma, the number is shifted, i.e., as it were, it is floating left or right. Therefore, the normal form of representation of numbers is called floating semicolon. The decimal number is 15.5, for example, in a floating semicolon format may be represented as: 0.155 · 102; 1.55 · 101; 15,5 · 100; 155.0 · 10-1; 1550.0 · 10-2, etc. This form of a decimal number of a decimal number of 15.5 floating semicolons is not used when writing computer programs and enter them into a computer (computer input devices perceive only linear data record). Based on this expression (2.7), to represent decimal numbers and enter them to the computer converts to the form

where p is the order of the number

i.e., instead of the foundation of the number 10, the letter E is written, instead of a comma dot, and the multiplication sign is not put. Thus, the number 15.5 in a floating semicolon format and a linear recording (computer representation) will be recorded in the form: 0.155E2; 1.55E1; 15.5e0; 155.0E-1; 1550.0E-2, etc.

Regardless of the number system, any number in a floating-semicolon can be represented by an infinite set of numbers. This form of recording is called abnormalized . For a unambiguous representation of floating point numbers use the normalized form of the number of the number, at which the Mantissa number must meet the condition

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

Condition (2.9) means that the mantissa should be a correct shot and have a digit after a semicolon, different from zero, or, in other words, if after the comma in the mantissa is not zero, the number is called normalized. Thus, the number 15.5 in the normalized form (normalized mantisum) in a floating point shape will look as follows: 0.155 · 102, i.e., normalized Mantius will be a \u003d 0.155 and order p \u003d 2, or in a computer representation of the number 0.155E2 .

The floating-semicolons have a fixed format and occupy four (32 bits) or eight bytes (64 bits) in the computer's memory. If the number takes 32 discharge in the memory of the computer, then this is the number of conventional accuracy, if 64 discharge, then this is the number of double accuracy. When recording a floating point, discharges are highlighted for storing the mantissa sign, order, mantissa and order sign. The number of discharges that are given to the procedure for the number of numbers determines the range of changes, and the number of discharges allocated for the storage of the mantissa is the accuracy with which the number is specified.

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

1) the orders of the numbers are aligned, over which arithmetic operations are performed (the order of smaller in the module of the number is increased to the value of the order of the number of the number of numbers, the mantissa decreases at the same number of times);

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

3) Normalization of the result obtained is performed.

Practical part

Real numbers (in contrast to integers) in computer equipment are called numbers having a fractional part.

When writing them instead of commas, it is customary to write a point. For example, the number 5 is an integer, and the number 5.1 and 5.0 are real.

For ease of displaying numbers that make values \u200b\u200bfrom a sufficiently wide range (i.e., both very small and very large), the form of recording numbers with procedure for the foundation of the number system. For example, a decimal number 1.25 can be submitted in this form as:

1.25*10 0 = 0.125*10 1 = 0.0125*10 2 = ... ,
or so:
12.5*10 -1 = 125.0*10 -2 = 1250.0*10 -3 = ... .

If the "floating" point is located in the Mantissa in front of the first meaning digit, then with a fixed amount of discharges left for the mantissa, a record of the maximum number of significant numbers is provided, that is, the maximum accuracy of the representation of the number in the machine. Therefore:

This, most profitable for a computer, representation of real numbers is called normalized.

Mantissa and the order of the Q-character number is taken to record in the system with the base Q, and the base itself is in the decimal system.

Examples of normalized presentation:

Decimal system binary system

753.15 \u003d 0.75315 * 10 3; -101.01 \u003d -0.10101 * 2 11 (order 11 2 \u003d 3 10)

0.000034 \u003d -0.34 * 10 -4; -0.000011 \u003d 0.11 * 2 -100 (order -100 2 \u003d -410)

The real numbers in computers of various types are recorded in different ways. At the same time, the computer usually provides a programmer with the ability to choose from several numeric formats most suitable for a particular task - using four, six, eight or ten bytes.

As an example, we give the characteristics of the formats of real numbers used by IBM-compatible personal computers:

Formats of real numbers Size in bytes Approximate range of absolute values Number of meaning decimal numbers
Single 4 10 -45 ... 10 38 7 or 8.
Real 6 10 -39 ... 10 38 11 or 12
Double 8 10 -324 ... 10 308 15 or 16
Advanced 10 10 -4932 ... 10 4932 19 or 20

This table shows that the form of a floating point numbers representation allows you to record numbers with high accuracy and from a very wide range.

When storing a floating point number is discharged discharges for mantissa, order, sign of the number and sign of order:

Let us show on the examples how some numbers are recorded in a normalized format in a four-scale format with seven discharges to record order.

1. Number 6.25 10 \u003d 110.01 2 \u003d 0.11001

  • 2 11:

2. Number -0.125 10 \u003d -0.0012 \u003d -0.1 * 2 -10 (negative order is recorded in an additional code):

| Planning lessons for the school year (GEF) | § 1.2. Presentation of numbers in the computer

Lessons 6 - 7
§ 1.2. Presentation of numbers in the computer

Keywords:

Discharge
unsigned representation of integers
representation of integers with a sign
Representation of real numbers

1.2.1. Representation of integers

The computer's prompt memory consists of cells, each of which is a physical system consisting of a certain number of homogeneous elements. These elements have two resistant states, one of which corresponds to zero, and the other one. Each such an element serves to storing one of the bits - the discharge of the binary number. That is why each cell element is called bit or discharge (Fig. 1.2).

Fig. 1.2. Memory cell

For a computer representation of integers, several different methods differing from each other with the number of discharges are used (8, 16, 32 or 64 discharges are usually assigned to integer numbers) and the presence or absence of a sign discharge. An insignificant representation can be used only for non-negative integers, negative numbers are only in a sign form.

An insignificant representation is used for objects such as cell addresses, all kinds of counters (for example, the number of characters in the text), as well as the numbers that indicate the date and time, the size of graphic images in pixels, etc.

The maximum value of an integer non-negative number is achieved in the case when the cells are stored in all discharges. For n-discharge presentation, it will be 2 N -1. The minimum number corresponds to n zero stored in n memory discharges, and is zero.

Below are the maximum values \u200b\u200bfor unsigned integer N-bit numbers:

To obtain a computer representation of an unsigned integer, it is enough to translate a number into a binary number system and supplement the result from the left zeros to standard bit.

Example 1.. The number 53 10 \u003d 110101 2 in the eight-bit presentation has the form:

The same number 53 in sixteen discharges will be recorded as follows:

When viewed with the sign, the oldest (left) discharge is given under the sign of the number, the remaining discharges are under the number. If the number is positive, then 0, if the number is negative - 1. Such a representation of numbers is called direct code.

In the computer, direct codes are used to store positive numbers in storage devices, for performing operations with positive numbers.

On the website of the Federal Center for Information and Educational Resources (http://fcior.edu.ru/) there is an information module "Number and its computer code". With this resource, you can get more information on the topic studied.

To perform operations with negative numbers, an additional code is used to replace the operation of subtraction by adding. You can find out the algorithm for the formation of an additional code using the information module "Additional Code" placed on the website of the Federal Center for Information and Educational Resources (http://fcior.edu.ru/).

1.2.2. Representation of real numbers

Any real number A can be recorded in exponential form:

Where:

m - Mantissa number;

p is the order of the number.

For example, the number 472 LLC LLC can be submitted as follows: 4.72 10 8, 47.2 10 7, 472.0 10 6, etc.

With the exponential form of recording numbers, you could occur when performing calculations using a calculator when the following type records were received as an answer: 4.72e + 8.

Here the "E" sign denotes the base of the decimal system of the number and is read as "multiply by ten to degree."

From the above example, it can be seen that the position of the comma in the number of numbers may vary.

For uniformity, Mantissa is usually written as the correct fraction having a digit after a semicolon different from zero. In this case, the number 472 LLC LLC will be presented as 0.472 10 9.

A real number can occupy in a computer 32 or 64 discharge. At the same time, discharges are highlighted for storing the mantissa sign, a sign of order, order and mantissa.

Example:

The range of representation of real numbers is determined by the number of discharges allocated to store the order of the number, and the accuracy is determined by the number of discharges reserved for the storage of the mantissa.

The maximum value of the number of numbers for the example above is 1111111 2 \u003d 127 10, and, therefore, the maximum value of the number:

0,11111111111111111111111 10 1111111

Try to find out what the decimal equivalent of this value is.

A wide range of real numbers representation is important for solving scientific and engineering tasks. At the same time, it should be understood that algorithms for processing such numbers more labor-intensive compared with the algorithms for processing integer numbers.

THE MOST IMPORTANT THING

For a computer representation of integers, several different methods differing from each other with the number of discharges (8, 16, 32 or 64) and the presence or absence of a sign discharge are used.

To represent an unsigned integer number, it should be translated into a binary number system and supplement the resulting result from the left zeros to standard bit.

When submitted with the sign, the oldest discharge is given under the sign of the number, the remaining discharges are under the number. The number is positive, then 0, if the number is negative, then 1. The positive numbers are stored in the computer in the direct code, negative - in the additional one.

When stored in the computer of real numbers, discharges are allocated to storing the sign of the order of the number, of the very order, the sign of the mantissa and the mantissa. In this case, any number is written as follows:

Where:

m - Mantissa number;
q is the basis of the number system;
p is the order of the number.

Questions and tasks

1. Familiarize yourself with the presentation materials for the paragraph contained in the electronic application to the textbook. Use these materials when preparing answers to questions and execute tasks.

2. How are whole positive and negative numbers presented in the computer's memory?

3. Any integer can be considered as a real, but with a zero fractional part. Justify the expediency of the presence of special methods of computer representation of integers.

4. Prepare the number 63 10 in an unsigned 8-bit format.

5. Find decimal equivalents of numbers by direct codes recorded in an 8-bit format with a sign:

a) 01001100;
b) 00010101.

6. Which numbers 443 8, 101010 2, 256 10 can be saved in an 8-bit format?

7. Record the following numbers in natural form:

a) 0.3800456 10 2;
b) 0.245 10 -3;
c) 1,256900e + 5;
d) 9,569120E-3.

8. Record the number 2010.0102 10 five in various ways in exponential form.

9. Record the following numbers in an exponential form with a normalized mantissa - the correct fraction having a piece of digitally different from zero:

a) 217.934 10;
b) 75321 10;
c) 0.00101 10.

10. Picture a scheme connecting the basic concepts discussed in this paragraph.

Subject: Presentation of numbers in the computer. Fixed and floating semicolon format. Direct, reverse and optional code.

Reiteration: Transfer of integers into a binary number system:

13 10 = but 2 Similarly:

13 10 =1101 2

1345 10 =10101000001 2


Representation of integers in the computer.

All information processed by computers is stored in binary form. What way is this storage?

The information entered into the computer and arising during its work is stored in its memory. Computer memory can be represented as a long page consisting of separate lines. Each such string is called memory Cell .

Cell - this is a part of a computer memory that enlists the information available for processing. separate team processor. The minimum addressable cell of the memory is called bytes - 8 binary discharges. The sequence number of the byte is called it address .

cell (8bit \u003d 1B)

machine word.

The memory cell consists of a certain number of homogeneous elements. Each element is able to be in one of two states and serves to image one of the digits of the number. That is why each cell element is called discharge . The numbering of discharges in the cell is made on the right left, the rightmost discharge has sequence number 0. This is the lowest discharge of the memory cell, the senior discharge has a sequence number (N-1) in the N-bit memory cell.

The content of any discharge can be either 0 or 1.

The contents of the memory cell is called machine word. The memory cell is divided into discharges, each of which stores the discharge of the number.

For example, the most modern personal computers are 64-bit, that is, a machine word and, accordingly, a memory cell consists of 64 discharges or bitov.

Bit - Minimum unit of information measurement. Each bit can take a value of 0 or 1. Bit Also called discharge EU memory cells.

The standard size of the smallest memory cell is equal to eight bits, that is, eight binary discharges. A combination of 8 bits is the main unit of data representation - bytes.

Byte (from English byte - syllable) - part of a machine word, consisting of 8 bits, processed in a computer as one. On the screen, the memory cell consisting of 8 digits is byte. The younger discharge has sequence number 0, a senior discharge - sequence number 7.

8 bits \u003d 1 byte

Two formats are used to represent numbers in the computer's memory: format with a fixed point and floating point format . Fixed-point format seem only integers , in a floating point format - real numbers (fractional).

In the overwhelming majority of tasks solved using a computer, many actions are reduced to operations over integers. This includes the tasks of an economic nature, when solving which data serves the number of shares, employees, details, vehicles, etc. The integers are used to designate the date and time, and for the numbering of various objects: elements of arrays, records in databases, machine addresses, etc.

Integers may be in a computer with a sign or no sign (be positive or negative).

Whole numbers usuallyoccupy one or two bytes and take in a single-out format values \u200b\u200bfrom 00000000 2 11111111 2 , and in two-byte format - from 00000000 00000000 2 Up to 11111111 11111111 2 .

Whole numbers with sign Typically occupy one, two or four bytes in the computer's memory, while the leftmost (senior) discharge contains information about the number of numbers. The plus sign is encoded by zero, and "minus" is one.

1101 2 10101000001 2

Discharge

(in this case +)

Missing older discharges to the whole byte are filled with zeros.

The computer technique uses three forms of recording (encoding) integers with a sign:straight the code , back the code , additional the code .

Direct code - This is the representation of the number in the binary number system, while the first bit is given under the sign of the number. If the number is positive, then in the first discharge it is 0 if the number is negative, the unit is specified in the first discharge.

In fact, the direct code is used almost exclusively for positive numbers.To record the direct code of the number you need:

    Submit a binary system

    Supplement the number of numbers by zeros to the penultimate senior discharge of an 8-bit or 16-bit cell

    Fill the older discharge by zero or unit depending on the number of numbers.

Example:the number 3 10 in the direct code of a single-path format will be presented as:


c.isll -3. 10 In the direct code of a single-tie format has the form:


Code For a positive number in the binary number system coincides with the direct code. For a negative number, all numbers are replaced with opposite (1 to 0, 0 to 1)invert, and a unit is entered into the sign discharge.

For negative numbers, the so-called optional code is used. This is due to the convenience of performing operations over the numbers of computing equipment.

Additional code Used mainly to represent negative numbers in the computer. Such code makes arithmetic operations more convenient to perform their computing equipment.

In an additional code, as well as directly, the first bit is allocated to represent the sign of the number. Direct and additional code for positive numbers coincides. Since the direct code is used almost exclusively for the presentation of positive numbers, and optional - for negative, it is almost always if in the first discharge 1, then we are dealing with an additional code. (Zero denotes a positive number, and the unit is negative).

Algorithm for obtaining an additional code for a negative number:

1. Find a direct number code (translate a number into a binary number system number without sign)

2. Get the reverse code. Change each zero per unit, and one on zero (invert number)

3. Add to reverse code 1

Example: Find an additional decimal code - 47 in a 16-bit format.

    Find a binary recording of the number 47 (direct code).

2. Invert this number (reverse code). 3. We add 1 to the reverse code and get the recording of this number in RAM.

Important!

For positive numbers, direct, reverse and additional codes are the same, i.e. Direct code. Positive numbers for presentation in the computer do not need to invert!

Why usedadditional code for the representation of a negative number?

It is easier to perform mathematical operations. For example, we have two numbers submitted in the Live Code. One number is positive, the other is negative and these numbers need to be folded. However, it is impossible to simply fold them. First, the computer must determine what it is for numbers. Finding out that one number is negative, it should be replaced by the operation of addition of subtraction. Then, the machine must determine which number is more modulo to find out the sign of the result and determine what to deduct from. As a result, a complex algorithm is obtained. It is much easier to add numbers if negative is transformed into an additional code.

Practical task:

Exercise 1. Burn direct, reverse and additional codes of the following decimal numbers using8-digit Cell:

64 10, - 120 10

Task 2. Record direct, reverse and additional codes The following decimal numbers in a 16-bit mesh

57 10 - 117 10 - 200 10

If we could look into the content of computer memory, we would see the following:

This drawing reflects Rule number 1: The data (and programs) in the computer's memory is stored in binary form, i.e. In the form of chains of zero and units.

Rule number 2:data presentation in the computer is discrete.

What is discreteness?

The closest answer is: "Separate"

Note: The discrete set consists of elements separated from each other. For example, the sand is discretened because it consists of individual grains. And the water or oil is continuous (within our sensations, since individual molecules can not even feel anyway)

For example, the image is built in the form of a set of points, i.e. Discretely.

Rule number 3:many modes in memory are limited and of course.

Presentation of numbers in the computer.

Whole numbers in the computer. (Fixed semicolon format)

Any computing device (computer, calculator) can only work with a limited multiple number. Look at the Calculator scoreboard, 10 characters are placed on it. The biggest positive number is placed on the scoreboard:

9

9

9

9

9

9

9

9

9

The largest largest negative number:

9

9

9

9

9

9

9

9

9

Similarly, the case is also in the computer.

For example, if a memory cell of 16 bits is allocated for an integer, the largest positive number will be:

0

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

In the decimal system, it is equal:

2 15 -1=32767

Here the first bit plays the role of the sign of the number. Zero - a sign of a positive number. The most module is a negative number equal to -32768.

How to get his internal representation:

1) translate a number in 32768 to a binary number system, it is equal
1000000000000000 - Received direct code.

2) invert this double code, i.e. replace zeros by units, and units on zeros - got code.

0111111111111111

3) To add a unit to this binary number, as a result we will get:

1

0

0

0

0

0

0

0

0

0

0

0

0

0

0

0

The unit in the first bit indicates the "minus" sign.

(No need to think that the code received is "minus zero". This code represents the number -32768.)

These are the rules of the machine representation of integers. This internal representation of the number is called additional code.

If N bit is given under an integer in the computer's memory, then the range of values \u200b\u200bof integers: [-2 n-1 -1, 2 n -1]

We reviewed the format for the representation of integers with a sign, i.e. Positive and negative. It happens that you need to work only with positive integers. In this case, the format of the representation of integers without a sign is used.

In this format, the smallest number is zero, and the largest number for the 16-bit cell:

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

In the decimal number system, it is 2 16 - 1 \u003d 65535, twice as many modulo than in the view with the sign.

Whole numbers in the computer. (Floating semicolon format)

The largest number of different calculators can be different. At the simplest calculator - 999999999. If you add to it another unit, the calculator will give an error message. And on a more "smart" calculator, the addition of a unit will result in this result:

1

e.

+

0

9

This entry on the scoreboard is understood as follows: 1 x10 9.

Such a format for recording numbers is called floating.

1

e.

+

0

9

mantissa

the order of the number

In the computer number I can also be represented in a format with a fixed semicolons and in a floating point format.



Did you like the article? Share it