Data representation, and operation verification

Numerical Data representation:

Binary notation:

Base number system to the right:

In any number system, the number of digits on each of the allowed count symbols is referred to as the base number system.

Each bit corresponds to a value indicating that the bit position in the digital medium, this value is called the weight digits.

Numeric conversions: binary, decimal, octal, hexadecimal.

   Decimal integer to an arbitrary integer binary rule is: In addition to (In) modulo group; remainder to low, the balance being high;

   Any decimal binary decimal conversion rule is: by (in) yl rounding; first whole is high, the whole low. 

  Binary to octal: 3 group;

  Binary to Hex: 4 group;

  Other decimal to binary: the right to expand by adding the law;

A signed, he said:

Rule number notation: "0" indicates a positive sign "+", "1" represents the negative sign "-"

Binary code system: source, the inverted, complement and shift.

Rule: positive original code, anti-complement and the same code;

Is a negative inverted original code except the sign bit bitwise, in addition to the original code is the complement sign bit plus a bitwise;

Original code: the value "0" of the original code in two forms: [+ 0] = 00000000 original, [- 0] = 10000000 original.

Inverted: the value "0" has two inverted form: [+ 0] = 00000000 trans, [- 0] = 11111111 trans.

Complement (code definitions: [X] Complement = X + 2 ^ n, n is the number of coded bits): the value "0" is only one kind of complement form: [+0] Complement = [-0] = 00000000 complement .

Shift: shift used to represent floating-point exponent.

Order code generally is an integer, it is usually only used to represent frameshift integer. For fixed-point integer X, it is frameshift: [X] shift = 2 ^ (n-1) + X, where -2 ^ (n-1) <X <2 ^ (n-1), n ​​is here X original digits.

Rule: original code symbol bit positive number is reversed, i.e., to obtain a frameshift. Negative sign bit together with the original code is reversed, end plus 1, i.e. to give frame shift (change complement and equivalent). Complement and shift: opposite sign, the same value bits.

 

 

 

Floating point representation principle:

Floating point representation, the position of the floating decimal point may be needed.

Format model:

 

 

8-bit word length code binary floating-point number from the original 5-bit mantissa exponent +3.

When the same word length, a greater range of floating-point number represents higher precision!

Float machine-readable (storage) format:

 

 

R: base-code order, 2 implicit agreement.

E: order code, fixed-point integer, complement or frameshift said number of bits which determines the range of values.

M: the mantissa, for the decimal point, represents the original code, or complement, the number of bits which determines the accuracy of the numbers; the number of positive and negative symbols represent numbers.

Character representation:

ASCII code (number of characters: 128)

Memory width: 7b (valid bit) + 1b (parity) = 8b

 

 

Chinese character input code:

Comprising: a digital code, phonetic code, shape code

Chinese characters within the code:

The computer stores the native code of the Chinese character information, exchange, retrieval operation, typically represented by two bytes.

GB Code: area code hexadecimal 10 to hexadecimal turn, coupled 2020H;

Machine code: GB code + 8080H (ASCII and difference), or converted to area code 16 hex + A0A0H

Chinese font code:

Character font glyph code represented by the dot code, is output in the form of Chinese characters.

Data processing and storage:

Shift operation: shift logic (digital position change), arithmetic shift (sign bit change, the digital position change)

Digital expansion and compression:

Sign extension: directly sign bit (0/1) is filled into an extension bit;

0- expansion: high average full complement of 0 (for unsigned);

Median compression: abandoned high, stay low;

Data storage (byte addressing):

Little-endian mode: low small address unit storing data (i.e., the trailing end);

Big-endian mode: the lower large cells for storing data address (i.e., the trailing end);

Aligned data word:

Press boundary alignment, the boundary is not aligned;

The basic operation methods:

Fixed point represented by general complement, participants sign operation;

Complement addition and subtraction:

 

 Operation process:

 

 Logic implementation:

 

 

Overflow judgment:

  Spillage is the operation result exceeds the range of the number represented. Only when the number of the same two symbols or two symbols the sum of the number of distinct subtracting it may overflow.

  When the fixed-point addition and subtraction operations overflow occurs, the result of calculation is wrong.

  Complement fixed point addition / subtraction operation overflow determination of three methods :

1) the use of a sign bit: the same two symbols only need to participate in the operation, the result operand symbols are different, the result overflows;

2) double sign bit (also referred to as complement modulo 4): two identical sign bit of the result, indicates that no overflow; two different sign bit of the result indicates overflow, the highest at this time represent the true sign bit symbols ;

3) using a sign bit, according to the case of carry overflow data bits is determined: sign bit of the C S and the highest bit of the C . 1 the same, not overflow or overflow.

Check data

Parity:

The addition of a parity bit, so that the number of 1s is odd or even.

Parity can not find even bit wrong, you can not locate the error.

Hamming check:

Hamming code is a multi-packet parity; :: principle is valid check bits added to the information of several bits formed in the Hamming code, and the bit assigned to each parity group number in the Hamming code. When a bit error will cause the value of the parity bit about a few changes, which can be found not only wrong, but also pointed out the wrong location, provide a basis for automatic error correction.

Code organized into several groups, each parity test; able to check whether an error occurred, can locate misplaced;

 

 

Cyclic redundancy check (CRC code):

Use test data to be divided by an agreed code can be divisible indicates that the data is correct, otherwise a misalignment correction by cyclic shift.

Cyclic redundancy check code encoding laws are as follows:

① the N bits of significant information to be encoded as a polynomial representation M (X);

② The M (X) left by K bits, to give M (X) × X- K , so that a space K bits to K bits assembled remainder (i.e., parity bit);

③ Select a K + 1 bit generating polynomial G (X), of M (X-) × X- K modulo 2 addition;

④ the left after K bits of significant information and the remainder R (X) modulo 2 addition and subtraction, splicing the CRC code, the CRC code at this time is a total of N + K bits. 

 

 Representation and fixed-point arithmetic

Fixed-point representation

  In the fixed-point notation conventions: All data of the decimal point position fixed. Typically, the decimal point is fixed at the front end or the significant digits, which form two fixed points: the decimal point and fixed-point integer. 

1. It represents a range of fixed-point decimal

  I.e. decimal point decimal fraction, the decimal point position is fixed until a most significant bit after the sign bit.

2. It represents a range of fixed-point integer

  That is pure fixed-point integer integer, fixed after the least significant digit decimal point position implied.

 Fixed-point arithmetic 

1. Fixed-point shift operation

  Fixed-point arithmetic shift operations include shift, logic shift and rotate.

Arithmetic shift:

   For arithmetic shift is signed numbers, symbols must remain constant operand during shifting. When the left one, as an overflow does not occur, then the value × 2; and when the right one, without taking into account the last bit truncated by the displacement of the mantissa, then the value of / 2.

 

 

Logical shift:

  Operands as unsigned look.

  Shift rule: when a logical shift left, lost high displacement, low add 0; logical shift right, throw low displacement, high Tim 0; regardless of left or right 0 is added.

Circular shift:

  Features: removal of digital data has been pushed into.

  A cycle: Carry flag CF;

  Small cycles: Do not Carry flag.

  Cyclic shift operation for the low byte and high byte data interchange data .

2. sign extension 

  An arithmetic operation in a computer, it is sometimes necessary to use more bits converts the number to have some representation of a given number of representation.

  Positive sign extension is very simple, original form on the sign bit is moved to a new form of the sign bit, an additional bit indicates that all the new forms are filled with zeros.

  The method of the negative sign extension according to the number of different machines. Original code symbols representing negative numbers in the positive spreading the same number, but this time only the sign bit is 1. Complement representation of negative numbers extension method is: the original form of the sign bit of the symbol bit moves to new forms, new forms of showing all the additional bits are used to fill 1.

Guess you like

Origin www.cnblogs.com/zyh19980816/p/11923543.html