2.1 Binary Numbers

42 阅读2分钟

1. Exam Points

  • Represent data using different number bases/systems.
    • Decimal: 19 (0-9), Binary: 1111 (0-1), Hexadecimal: A9F (0-9 A-F)
    • Number of items that can be represented using n bits: 2^n
    • The largest number that can be represented using n bits: 2^n-1
    • Reresenting colors using different color bases.
  • Convert between two number bases.
    • Decimal <-> Binary
    • Decimal <-> Hexadecimal
  • Overflow errors and Round-off errors
  • Analog signal and digital signal, and how analog signals are converted to digital signals.

2. Knowledge Points

(1) Representing Data

  • Data are a collection of discrete or continuous values that convey information.

  • Computing devices represent data digitally using bits (1 and 0).

  • 1 byte = 8 bits.

  • Commonly used number bases/systems: image.png

  • Converting numbers between different number bases.

    • Convert Binary/Hexadecimal to Decimal ( * and + )
    image.png
    • Convert Decimal to Binary/Hexadecimal ( / and %, write reversely)
    image.png
  • Representing data using different number bases.

    image.png
  • ASCII

    • ASCII is used to convert text to binary form so computers can read it.
    • These standard character sets use 7 bits.
    • Therefore, ASCII can only represent 128 characters from 0 to 127. image.png

(2) Representing Numbers

  • Integer number

    • Computers use binary (base 2) notation. (Ex. 11 is 1011)
    • How many numbers can be represented using n bits? 2^n
    • The largest integer that can be represented using n bits? 2^n-1
    • Overflow Error: Integers are represented by a fixed number of bits, if an integer is out of the range, then overflow errors occur. (Ex. store 18 using 4 bits)
  • Float number

    • Float numbers are imprecise in computers since computers use a fixed number of bits to store numbers. (Ex. 6.3 may be stored as 6.2999997).
    • Round-off Errors (舍入误差) : In programming languages, the fixed number of bits used to represent real numbers/float numbers limits the range and mathematical operations on values; this limitation can result in round-off and other errors.

(3) Representing Colors and Images

  • The human eye primarily detects red, green, and blue. Other colors are a combination of these colors in different amounts.
  • Examples image.png
  • Images are composed of pixels, each of which contains a specific color value.
  • Resolution (分辨率): a measure of the sharpness of an image. (Ex. 1920 x 1080).
  • Bit depth (位深) : The number of bits used to record the color of each pixel point. (记录每个像素点颜色时使用的位数。)

(4) Representing Videos

  • Videos are made from a series of static images refreshed quickly.
  • FPS(每秒帧数): refers to the number of frames per second. The higher the number of frames per second, the smoother.
  • Ex. Movie: 24fps

(5) Representing Sound

  • Signal : used to transmit information, normally electrical signals.
    • Analog signal: are continuous and vary smoothly over time. It can take on any value(infinite) within a certain range. (All signals that are natural or come naturally are analog signals).
    • Digital signal: are discrete and represented by a series of separate values. image.png
    • Analog can be affected by noise during transmission while digital signals are more resistant to noise.
    • Analog signals can be converted to digital signals.
    • Convert analog signals to digital signals.
      • Sampling (采样)
      • Quantization (量化)
      • Encoding (编码)
        image.png

3. Exercises