ch6_1 Computing method in computer

  • representation of numbers in computer
  • computing method
  • Calculator design

reference materials
insert image description here

insert image description here
This chapter mainly introduces the calculation method in the computer

  1. unsigned and signed numbers
  2. Fixed-point and floating-point representations of numbers
  3. fixed-point arithmetic
  4. Four arithmetic operations of floating point
  5. ALU

1. Unsigned and signed numbers

1.1 Unsigned numbers

insert image description here

1.2 Signed numbers

computer,

  • Representation of decimal point data:
  1. The sign bit is required to be placed in the highest bit, that is, the leftmost part of the register.
  2. The position of the decimal point is given by convention.
    The position of the decimal point is the one after the sign bit.
  • representation of integer data
  1. The sign bit is required to be placed in the highest bit, that is, the leftmost of the register.
  2. The position of the decimal point. In integer data, the position of the decimal point is agreed at the end of the data.

insert image description here

1.3 Original code representation

The native notation is actually signed absolute value notation by adding a sign bit.

将最高位作为符号位(0表示正,1表示负),其它数字位代表数值本身的绝对值的数字表示方式。

0: indicates positive number, sign bit
1: indicates negative number, sign bit.

  • Representation of integer data,
    n represents the number of digits in the numerical part,
    insert image description here
    注意, 上图中的2^4, 代表是将其转化为二进制数是, 1 0000, 代表的是16的二进制数形式,然后加上+ 1110

  • Representation of decimal point data:
    In the decimal point form, 0 represents a positive number, 1 represents a negative number, and the original data with a decimal point is directly represented later.
    insert image description here
    Conversely, knowing the original code how to find real data,

insert image description here
In the original code representation, when doing addition and subtraction, there will be the following problems;
insert image description here

1.4 Two's Complement Notation

insert image description here

Adding "modulo" to a negative number will get the complement of the negative number.
When a positive number and a negative number are complements of each other, the sum of their absolute values ​​is the modulus.
insert image description here

For example, when the counter is four bits, when the modulo 16 method is used, when the value is greater than or equal to 16, the carry part will be automatically discarded;

Due to the existence of the concept of complement code and the concept of modulus,
the subtraction operation can be replaced by the addition operation.

  • The complement of a positive number is itself,
    so in order to distinguish whether the complement is the complement of a positive number or the complement of a negative number, add 2 4 + 1 2^{4+1}24 + 1
    Two numbers that are complementary to each other, plus the modulus
    insert image description here

当真值为负时,补码可由原码除符号位外每位取反,末位加1求得。

  • Definition of two's complement:
  • Integer's complement

insert image description here

  • decimal's complement
    insert image description here

insert image description here
insert image description here

1.5 Inverse notation

The representation form of the complement code is: when the number is negative, the sign is 1, and each bit of the value part is inverted + 1 is added to the last bit;

Representation of one’s complement code: In the process of forming the complement code, the last bit is not added with 1;

1.6 Summary of three representations of machine numbers

  • The highest bit is the sign bit, and "," (integer) or "." (decimal) is used to separate the value part from the sign bit.

  • For integers, original code = complement code = complement code

  • For negative numbers, the sign bit is 1, and its value part.

Complementary code: except the sign bit of the original code, each bit is inverted and added at the end;
Inverse code: each bit of the original code is inverted except the sign bit;

1.7 Frameshift representation

There is only one sign bit difference between the complement code and the code shift, and the code shift of the value bit is exactly the same as the complement code.

2. Practice section

insert image description here

insert image description here

Guess you like

Origin blog.csdn.net/chumingqian/article/details/130257455