Learning "in-depth understanding of computer systems (third edition)" Chapter summary

Learning "in-depth understanding of computer systems (third edition)" Chapter summary

Three important figures indicate

  • Unsigned coding: representations based on a conventional binary representation is greater than or equal to 0.
  • Floating-point encoding: Indicates the most common way to signed integer, it can be positive or negative
  • Float Code: Version 2 is expressed in scientific notation base of real numbers

It denotes an object arrangement rule byte

  • Little-Endian (little endian): Some machines select objects stored in the order from the least significant byte to most significant byte, least significant byte at the top becomes little-endian fashion in memory.
  • Big endian big endian): Some machines are stored in the order from the most significant byte to least significant byte, most significant byte at the top becomes big endian manner.
  • Double-ended method (bi-endian): they can be configured as a big-endian or little-endian machine to run. However, the reality is: upon selecting a particular operating system, then also fixed byte order.

Conversion between signed and unsigned numbers

Allowed to make the C language cast between various types of digital data.

Results casts bit value is kept unchanged, except for changing the way of explanation of these bits.

When performing a calculation, if one of its operands is the other symbol is unsigned, then the C language will implicitly cast signed number into an unsigned number, and assuming that the two numbers are non- negative, to perform the operation.

Integer arithmetic:

Unsigned adder ①: The
important conclusions: forming a modulo adder Abelian group, exchangeable binding, each element has an additive inverse.
② complement addition;
non-complement of ③;
④ unsigned multiplication;
⑤ complement multiplication:
important conclusions: Set an unsigned integer binary representation, for any kO, has the following formula:
namely: a binary representation multiplied by the number, a bit pattern corresponding to the right complement of k 0 (without overflow), corresponds to a shift operation, C expression x << k is equivalent to x * pwr2k, a number of C language compiler to shift the view , a combination of addition and subtraction to eliminate an integer multiplied by a constant in many cases.
For example: x * 14, using the equation 14 = compiler multiplication rewritten as (x << 3) + (x << 2) + (x << 1), to achieve a multiplication replaced three shift operation and three adders, improve the operation efficiency reduced clock cycle.
⑥ complement division:
rounded towards zero: multiplicative inverse operation, i.e. performs arithmetic right shift of k bits is divided, because the shift resulting in rounding down, rounding towards zero in accordance with the requirements, by biasing, could = correct rounded result.

IEEE floating-point number represents:

① IEEE floating-point representation:

  1. Symbols: s 1 and 0 negative negative positive decision value V by, for V = 0 otherwise explained.

  2. Mantissa: M is a binary fraction, which ranges from 1 - 2-ε, or 0 - 1-ε

  3. Order Code: E is the effect of floating-point-weighted, the weights E is a power of two (possibly negative)

② The floating-point number by bit is divided into three fields, are encoded respectively, similar to scientific notation:

  1. A separate sign bit s, direct encoding symbol s

  2. k-bit exponent field, exp = e k-1 ··· e0, codec E

  3. N-bit fraction field, frac = fn-1 ··· f0, coding the mantissa M, but this value depends on whether E 0

③ floating-point representation of the three cases:

  1. Normalized value:
    generally, when not all 0 exp, not all 1, the decoding indicates this to bias a signed integer, i.e. E = e - Bias, e is unsigned, e represents the order of the code bits encoding ek-1 ··· e0, the bias is equal to a (single-precision k = 8, double k = 11) of the offset value, thereby producing the index, i.e., in the range -126 to + :( single-precision 127, double -1022 + 1023), for small values as descriptions frac F, period 0≤f <1, which is a binary representation 0.fn-1 ··· f0, when the mantissa is defined as M = 1 + f when called implicit representation to 1 at the beginning, so that M = 1.fn-1 ··· f0, because the binary base 2, and we can always adjust the exponent within the range does not overflow, so that the range of the mantissa M in total 1≤M <2, M is consistent with the scope defined by IEEE, thereby indicating a decimal.

  2. Denormalized value:
    When the exponent exp domain all 0, the value of exponent E = 1-Bias, mantissa value M = f, are not included at the beginning of an implied (why), non-normalized values for is 0 and very close to zero decimal, because the normalization requirements M≥1, so I can not express 0, +0.0 actually floating-point bit patterns that represent all 0s, and when the sign bit is 1 time to get -0.0, gradually overflow property such that a uniform value approaches 0.0 (?)

  3. Special value:
    when the whole domain exponent exp 1, 0 represents infinity when the frac whole, to determine positive and negative infinity, infinity can result indicates overflow sign bit indicates positive or negative when non-zero fraction field, NaN referred the acronym is not a number, a number of the operation result is an imaginary number, can not be represented.

Guess you like

Origin www.cnblogs.com/lilei0915lgz/p/11896696.html