跳转至

Information Representation

Binary Number Represent

  • Information variables represented by physical quantities.
  • For digital systems, the variables take on discrete values.
  • Two level, or binary values are most prevalent values in digital system.
  • Binary values are represented abstractly by:
  • digits \(0\) and \(1\)
  • words (symbols) False (\(F\)) and Ture (\(T\))
  • words (symbols) Low (\(L\)) and High (\(H\))
  • and words On and Off
  • Binary values are represented by values or ranges of values of physical quantities.

Signal-Examples-Over-Time

  • Analog : continuous in value & time
  • Digital : discrete in value
    • Asynchronous 异步 : continuous in time
    • synchronous 同步 : Discrete in time

Note

计算机是由时钟信号控制,故其为 synchronous 同步

Signal-Example-Physical-Quantity-Voltage

  • threshold region : The fact that the input ranges are wider than the output ranges allows the circuits to function correctly in spite of variations in their behavior and undesirable “noise” voltages that may be added to or sub-tracted from the outputs.
  • noise margin 噪声容限 : Maximum allowable noise (0.1~0.4 & 0.6~0.9 in picture)

Note

输出要求比输入要求更加严格,以保证其抗干扰能力。

Why is binary used?

Other values need more range. So it would require complex and costly electronic circuits, and the output still could be disturbed by small “noise” voltages or small variations in the circuits occurring during their manufacture or use. As a consequence, the use of such multivalued circuits is very limited.

  • Other physical quantities:

    • CPU : voltage
    • Disk : magnetic field direction
    • CD : surface pits/light
    • DRAM 内存条 : electrical charge 电容
  • Carry Counting System : positive radix, positional number systems.

    A number with radix \(r\) is represented by string of digits :

    \[A_{n-1}A_{n-2}...A_1A_0.A_{-1}A_{-2}...A_{-m+1}A_{-m}\]

    in which \(0 \leq A_i \leq r\) and . is the radix point.

    The string of digits represents the power series 全展开式 :

    \[(Number)_r=\begin{matrix}\underbrace{(\sum_{i=0}^{n-1}A_i \times r^i)}\\\text{Interger protion}\end{matrix}+\begin{matrix}\underbrace{(\sum_{j=-1}^{-m}A_j \times r^j)}\\\text{Fraction protion}\end{matrix}\]
  • converting R-Base to Decimal : \(\sum (\text{digit} \times \text{respective power of R})\)

  • converting Decimal to R-Base : Repeatedly divide integral part. Repeatedly multiply the fractional part. Join the two results with a radix point.

Warning

the process of fractional part may repeat forever.

Solution

Specify number of bits to right of radix point and round or truncate to this number.

  • Special Powers of 2 :
    • \(2^{10} = 1024\) is Kilo, denoted K
    • \(2^{20} = 1048576\) is Mega, denoted M
    • \(2^{30} = 1073741824\) is Giga, denoted G
    • \(2^{40} = 1099511627776\) is Tera, denoted T

representation of numeric data

  • fixed-point 定点 ([sign, unsigned] integer number) / floating-point 浮点 (real number)

Note

定点同样可以表示小数,但需要提前固定小数位

  • machine number / true number
  • sign integer encoding methods

    • sign-and-magnitude : the value parts of positive and negative is same (two ways to represent 0)
    • complements

      • 1’s complement : 反码 \(\sim x\)
      • 2’s complement : 补码 \((\sim x) + 1\)
      • two’s biased notation: \(((\sim x) + 1) + 2 ^ n\)

      Note

      也叫移码,保证机器码和真值的相对大小相同

  • sign extension : copy the sign bit to the remaining bits

  • truncating
  • negation : \(x + \sim x = -1 \to -x = \sim x + 1\)
  • reflect on fractional binary numbers : bits to right of binary point represent the fractional powers of 2.
  • floating point numbers : larger number range / fractions / precision
  • floating point: - in binary : \(\pm 1.\overline{xxxx}_2 * 2^{\overline{yyyy}}\) - \(\pm\) : sign - \(\overline{xxxx}\) : fractions (accuracy) - \(\overline{yyyy}\) : exponent (range) - sign + exponent + fractions (convenient to compare)
  • IEEE 754 : 1 sign + 8 exponent + 23 fractions - \(x = (-1)^s \times (1 + \text{fraction}) \times 2 ^ {\text{exponent - bias}}\) - single bias = 127 - double (1 + 11 + 52) bias = 1023

    Note

    • double 相比 single 主要增加小数精度
    • exponent 全 0 与全 1 有特殊含义
      • 全 0 : hidden bit is 0 \(\text{sign} \times (0 + \text{fraction}) \times 2 ^ {\text{1 - bias}}\)
      • 全 1 :
        • fractions 全 0 : \(\pm \infty\)
        • 非全 0 : \(\text{NaN}\) (not a number)
  • Limitation : exponent is too big ( Overflow ) or too small ( Underflow )

  • Basic idea :

    • First compute exact result
    • make it fit into desired precision
      • possibly overflow if exponent too large
      • possibly round to fir into frac
  • Rounding :

    • Towards zero
    • Round down
    • Round up
    • Nearest Even (default)

    Example

    Rounding 1.4 1.6 1.5 2.5 -1.5
    Towards zero 1 1 1 2 -1
    Round down 1 1 1 2 -2
    Round up 2 2 2 3 -1
    Nearest Even 1 2 2 2 -2

    Note

    • Nearest Even 不易累计误差
    • 通常在计算过程当中需要利用保护位/舍入位/粘滞位来使得运算结果更准确
      • 舍入位 Round / 保护位 Gard : 多保留两位保证运算结果的准确
      • 粘滞位 Sticky : 确定是否需要舍入
    • 浮点数的误差导致其不满足交换率

Binary Codes for Decimal Digits

  • decimal codes : BCD(8,4,2,1) / Gray / Excess3 code
Dicimal 8,4,2,1 Excess3 8,4,-2,-1 Gray
0 0000 0011 0000 0000
1 0001 0100 0111 0100
2 0010 0101 0110 0101
3 0011 0110 0101 0111
4 0100 0111 0100 0110
5 0101 1000 1011 0010
6 0110 1001 1010 0011
7 0111 1010 1001 0001
8 1000 1011 1000 1001
9 1001 1100 1111 1000

Note

  • Excess3 在相加时可以产生正确的进位

Non-numeric Data

  • logical values : n-bit binary numbers

  • Alphanumeric codes :

    • 7-bits ASCII Code
    • UNICODE

Data width and storage

  • Bit : The smallest unit that makes up a binary number.

  • Byte : 8bits

  • word size : different defination in different sides

  • Unit of Main Memory Capacity : KB, MB, GB, TB, PB, EB, ZB, YB

  • Unit of Frequency and Line Width : b/s kb/s Mb/s Gb/s Tb/s

评论