This paper mainly on the computer system in the representation of data and industrial IEEE754 standard to explain, if there is improper, please put forward to modify, please read!

directory

Source code representation

Inverse notation

Complement notation

Shift code representation

Fixed-point number

Floating point Numbers

Industrial standard IEEE754


Hello! Hello, I’m grey Ape! A super Bug writing sand carving program ape!

Today here and we record in the computer system in all kinds of data representation and the use of industrial standard IEEE754 method.

Let’s start with a concept:

All kinds of data in the form of computer representation is called machine number, its characteristic is the symbol of the number with binary number 0, 1. The actual value corresponding to the number of machines is called the truth value of that number. At the same time, machine number is divided into unsigned number and signed number. An unsigned number represents a positive number, with no sign bits in the machine number. For signed numbers, the highest bit of the machine number is the sign bit representing positive and negative, and the remaining binary bits represent numeric values. The number of machines with signs can be coded by source code, inverse code, complement code and shift code. These methods of encoding machine numbers are called code systems.

Next, explain the use of these coding methods respectively.

 

Source code representation

In source code representation, the source code of the value X is denoted as the source code [X]. If the machine word length is N (that is, represented by N binary numbers), the source code is defined as follows:

Note: The range in the above formula goes to 2 to the n minus 1 because the first digit of the binary number is positive or negative, which results in no number greater than or equal to 2 to the seventh.

For example, when the machine word length n is 8, the source codes of the following numbers are:

Note: when expressing decimals in binary numbers, the first decimal point represents 2 to the -1 power and the second represents 2 to the -2 power…… And so on.

The highest bit of the machine number is the sign bit, 0 represents the plus sign, 1 represents the minus sign, and the remaining bits are the absolute value of the number. Zero has two codes, namely:

The advantages of the original code representation method are that the correspondence between the truth value of a number and its original code representation is simple, the mutual conversion is easy, and the multiplication and division operation rules are simple by using the original code.

The disadvantage is that it is very inconvenient to use the original code to achieve addition and subtraction operations.

 

Inverse notation

In the representation of the inverse, the inverse of the value X is denoted as [X] inverse, and if the machine word length is N, the definition of the inverse is as follows:

For example, when the machine word length n is 8, the inverse of the following numbers is:

The highest bit of the machine number is the sign bit, with 0 representing a plus sign and 1 representing a minus sign.

When the sign bit is 0, the remaining bits are the binary values of this number.

But when the sign bit is 1, the other bits should be reversed, which is its binary value.

Zero has two codes, namely:

 

Complement notation

In the representation of complement, the complement of value X is denoted as [X] complement. If the machine word length is N, the definition of complement is as follows:

For example, when the machine word length n is 8, the complement of the following numbers is:

 

The highest bit of the machine number is the sign bit, with 0 representing a plus sign and 1 representing a minus sign.

When the sign bit is 0(that is, a positive number), the remaining bits are the binary values of this number;

But when the sign bit is 1(that is, negative), the other bits are not the binary value of this number, they need to be reversed by bits, and the lowest increment 1, is its binary value.

Zero has a unique encoding, i.e

When the two numbers represented by the complement code are added, as long as the result does not exceed the range of values that the machine can represent, the sign bit and the value bit can be treated equally. After modulo 2 is adopted for the result of operation, the new result is the result of this addition operation.

 

Shift code representation

Shift notation is defined by adding an offset to the number X and is often used to represent order codes in floating point numbers. If the machine word length is N and the specified offset is 2 to the power n-1, the shift code is defined as:

For example, when the machine word length n is 8, the source codes of the following numbers are:

When the partial sum is 2 to the power of n-1, the corresponding shift representation can be obtained by inverting the sign bits of the complement.

 

In addition to the above source code, complement these data representation methods, in the computer data representation there are fixed point number and floating point number two,

 

Fixed-point number

The so-called fixed point number is the number with the fixed position of the decimal point. The position of the decimal point is usually agreed in two ways:

Fixed-point integer (a pure integer with the decimal point after the least significant number place)

Fixed-point decimal (pure decimal, with the decimal place before the most significant number place)

 

Floating point Numbers

Floating point numbers, which are numbers with a variable decimal point, can represent a wider range of values,

First look at an example, when the machine word length is n, the number of complement and move the code number can be said, and its source code and the number of radix-minus-one complement can only say, because in the original code and radix-minus-one complement the 0 said to take two coding, the fixed-point number can indicate the numerical range is small, easy in operation because the result is beyond range and overflow, But because floating point numbers are numbers where the decimal point is not fixed, they can represent larger numbers.

Floating-point numbers are usually represented as follows:

Where M is the mantissa, R is the cardinal number (generally 2), E is the order code,

So if you want to say a floating point number, it is necessary to give the mantissa M, it determines the representation of floating point precision, to give exponent E at the same time, it points out that the position of the decimal point in the data, also determines the representation of a floating-point number range, this method says the number of known as the floating point number, the number of this method is also known as floating-point representation.

In floating-point representation, the code level is a signed pure integer and the mantissa is a signed pure decimal. The representation of floating-point numbers is shown in the following figure:

Order operator The code order Number of operators mantissa

As we can see from the above, the floating-point representation of a number is not unique. When the position of the decimal point changes, the order code also changes accordingly. Therefore, multiple floating-point forms can be used to represent the same number.

The range of values that can be represented by floating point numbers is mainly determined by the order code, while the precision of the values represented is determined by the mantissa. To make full use of mantissa to represent more significant digits, normalized floating-point numbers are often used. Normalization is to limit the absolute value of the mantissa to the interval [0.5, 1].

When the mantissa is represented by complement, the following problems should be noted:

① If the mantissa M≥0, then the normalized mantissa form is M=0.1XXX… X, where X can be 0 or 1, that is, the mantissa is limited to the interval [0.5, 1].

② If the mantissa M<0, the normalized mantissa form is M=1.0XXX… X, where X can be 0 or 1, that is, the mantissa of M is limited to the range [-1, -0.5].

If the order code of a floating point number (including the 1-bit rank character) is represented by an R-bit shift and the mantissa (including the 1-bit character) is represented by an M-bit complement, the range of values that such a floating point number can represent is as follows:

Note: If the presentation scope exceeds the computer’s presentation scope, it is called an overflow.

 

 

Industrial standard IEEE754

IEEE754 is an industrial standard for floating point numbers developed by IEEE. The standard is widely used at present. It is expressed as follows:

Where, is the number symbol of the number, when S is 0, it represents a positive number, when S is 1, it represents a negative number, E is the exponent (order code) is represented by shift code, is the mantissa, its length is P bits, and it is represented by the original code,

The computer mainly uses three forms of IEEE754 floating point number, namely, single precision floating point number, double precision floating point number and extended precision floating point number. The following table shows the format table of IEEE754 floating point number in three formats.

On the data in the computer representation method is summarized here for the first time, and will continue to update and improve.

Feel good remember to like attention yo!

Big bad Wolf accompany you to progress together!