This is the 9th day of my participation in Gwen Challenge

Decimal conversion to any base number

  • For integers: mod by division
  • For decimals: round by base

BCD

  • There will be invalid code for 8,421
  • Remaining 3 yards 8421 + 3
  • 2421 code is greater than or equal to 5 of the four bits of binary number in the highest bit is 1, less than 5 of the highest bit is 0, according to the inverse of the complement of 9

The bytecode

Each byte stores one character, small end (low → rightarrow→ high), big end

Check code

  1. Parity check code

    • Practice: add a check bit to the original code
    • Spacing: 2 // The spacing is the number of bits corresponding to two codes with different values, called the Hamming distance between the two code words.
    • Function: Can detect unusual digit error

    The location of the error cannot be determined

    The parity bit is used to make the digit of “1” in the whole parity code odd or even, and the odd digit becomes the odd parity.

  2. Haiming check code:

    • Practice:

    • Hamming code formula:
      2 k 1 p n + k 2^k – 1 \geq n + k
      : This expression means that it can be used for checkingerrorNumber of digits () is greater than or equal toOf the original data bits (n) and the parity bits (k)And.That is, all the numbers that can be represented by the check code, 2 to the k to the minus one correct probability, must be greater than or equal to any of the n plus k digits that can be wrong

    • Code spacing: L-1=D+C and D ≥ geq≥C that is, the larger the minimum code spacing L is, the larger the error detection bit D is, and the larger the error correction bit C is, and the error correction ability is always less than or equal to the error detection ability

    • Calculation: place the check code in the 2^ I ^ bit and use parity to determine the value

    • Error correction:

      Eie_iei is 0 if it is correct and 1 if it is wrong

  3. Cyclic redundancy check code

    • Practice: Splice R bit check code after K bit information code, and the length of the whole code is N bits. Also known as the (N, K) code
    • Divide by information code and polynomial ** ** take the remainder, as the check code R, and divide by the polynomial with CRC code at the receiving end, if it can be divided exactly, then no problem
    • If it’s not divisible, what’s the remainder? What’s wrong?

Data storage mode

In small-endian mode, the low-value bytes are processed first. In big-endian mode, the high-value bytes are processed first

Struct stores border alignment

  • Each member is aligned by its type, and the struct length must be an integer multiple of the largest aligned value in the member

Fixed-point number operation

Source complement reverse code shift

Fixed point means that the position of the decimal point in the number of machines is fixed

  • Source code: the highest bit of the number of machines represents the symbol of that number, the remaining bits represent the absolute value of the book
  • Complement: the positive numbers remain the same, and the negative numbers take the inverse plus 1 (in order to add them directly)
  • Radix-minus-one complement
  • Shift: number with bias, usually 2^n^
    • The representation of zero in the code shift is unique
    • There is only one sign bit difference between the shift and complement of a true value, and if the sign bit of x complement is reversed, the sign bit of X complement is reversed, and the sign bit of X complement is reversed, and the sign bit of X complement is reversed
    • When all shift codes are 0, the minimum truth value is -2^n^ 2^n^-1
    • Maintain the size of the law

Shift operation of fixed point number

Arithmetic shift

Logical shift

Used for unsigned numbers, all added with 0

Cyclic shift

What’s the use? Suitable for data conversion between low and high bytes

Sign extension

Positive numbers are all 0, negative original code inverse code 1, complement integer 1 decimal 0

All the negative numbers are 1 except for the complement where the decimal is 0

Overflow concept and discriminant method

Both single and double sign bits require overflow judgment circuits, i.e., xOR gates

Fixed-point number multiplication and division method: mainly master the principle and characteristics of complement code multiplication and division, unnecessary tangle for the operation process

(1). Fixed-point complement multiplication operation: Master the Booth algorithm and can be understood according to overflow. When 01 occurs, +[x] is needed for positive overflow; when 10 occurs, +[-x] is needed for negative overflow;

(2) Fixed-point number complement division operation: remainder and divisor are the same sign, upper quotient “1”; Remainder and divisor different sign, upper quotient “0”; And then the last step is constant “1”