Review¶
Day 01 7.11¶
Why Boolean type is 8-bit in C / C++ ?
1 Byte is the minimum element of memory addressing.
8-bit is the most efficient way for memory addressing.
An ISA can have multiple microarchitecture.
Compiler vs. Assembler
Assemble language is bijective to ISA, but programming language are not.
Compiler transform high level programming language to machine code.
Assemble transform assemble language to machine code.
Value Representation
Signed Magnitide 源码
most intuitive, but can not do calculation.
1's Complement 反码
can do calculation, but have +0 and -0, which wastes.
2's Complement 补码
can do calculation, no waste binary number.
-16 is 2's complement is itself
Scope of some reprentations
Unsigned \(0 \le x \le 2^n - 1\)
2's complement \(-2^{n=1} \le x \le 2^{n-1} - 1\)
Overflow
A trick to judge overflow :
two number adds, if positive gets negative, or vice versa, then it overflows.
A positive number plus a negative number never overflows.
How to move left ?
\(a << 1 = a + a\)
Operation Law of logic variable
xor operation is recursive.
Provided that \(X\ xor\ Y = Z\), then if two variable is known, the rest one can be determined.
A way to exchange X, Y
Day 02 7.12¶
取位 X AND M
打开位 X OR M
关闭位 X AND (NOT (M))
Single Presicion 32-bit¶
Normalized Form
\((127)_{10} = (01111111)_2\) is called offset.
\(N = (-1)^S \times 1.Fraction \times 2 ^{exp - 127}\)
\(1 \le exp \le 254\)
\(exp = 0 / 255\)for other forms
Other Precision
Double Precision 64-bit
Half Precision 16-bit
Logical Completeness Not more 1 or 0 signal can be considered.
创建日期: 2024.02.21 00:56:50 CST