'Computer Systems: A Programmer's Perspective 3rd (Randal E. Bryant)'를 주교재로 한 시스템 소프트웨어 강의 수업자료를 복습하며 정리한 것
Fractional Binary Numbers
- e.g) 111.11 -> 2^2 + 2^1 + 2^0 + 2^(-1) + 2^(-2)
IEEE Floating Point
- IEEE Standard 754
- Uniform standart for floating point arithmetic
- Nice standard for rounding, overflow, underflow
- Hard to make fast in H/W
- Representation
- Numerical Form (-1)^s * M * 2^E
- Sign bit s(positive or negative)
- Significand M(유효숫자, 가수부) - normally fractional value in range [1.0, 2.0)
- Exponent E(지수부)
- Encoding
- MSB bit s
- exp field encodes E(not equal to E)
- frac field encodes M(not equal to M)
- e.g.) Single precision : 32bits(1 + 8 + 23)
- Normalized Values
- exp != 000...0 and exp != 111...1
- Exponent coded as biased value
- E = exp - Bias(= 2^(k - 1) - 1) where k is # of exponent bits
- Significand coded with implied leading 1
- M = 1.xxx...x (xxx...x : bits of frac field)
- e.g.) Single precision
- Denormalized Values
- where exp = 000...0, E = 1 - Bias, M = 0.xxx...x
- possible results : +0, -0, closest to 0.0
- Special Values
- where exp = 111...1
- possible results : positive infinity, negative infinity, overflows, NaN
Rounding, addition, multiplication
- Rounding
- modes
- Towards zero
- Round down : 버림
- Round up : 올림
- Nearest Even(default) : 가까운 값으로 근사, .5의 경우 짝수가 되는 쪽으로
- modes
- Addition
- (-1)^s1 * M1 * 2^E1 + (-1)^s2 * M2 * 2^E2 = (-1)^s * M * 2^E (assume E1 > E2)
- M >= 2라면, M을 오른쪽으로 쉬프트하고, E 증가
- M < 1이라면, M을 왼쪽으로 k만큼 쉬프트, E를 kakszma rkath
- E가 범위를 벗어나면 overflow
- Multiplication
- ((-1)^s1 * M1 * 2^E1) * ((-1)^s2 * M2 * 2^E2) = (-1)^s * M * 2^E
- Sign s : s1 ^ s2
- M : M1 * M2
- E : E1 + E2
- M >= 2라면, M을 오른쪽으로 쉬프트, E를 증가
- E가 범위를 벗어나면 overflow
'CS > 시스템소프트웨어' 카테고리의 다른 글
05. machine-control (0) | 2022.10.31 |
---|---|
04. machine-basics (0) | 2022.10.30 |
02. Bits, Bytes, and Integers (0) | 2022.10.25 |