소수를 표현하는데는 크게 2가지 방법이 존재한다
1. Fixed-point Representation
2. Floating-point Representation
대부분의 경우 FP(Floating Point) 방식을 많이 사용하기 때문에 Floating Point Representation에 대해 알아볼 예정이다.
Floating Points Representation 방식은 말 그대로 소수점이 움직이는 방법이라고 볼 수 있다.
Numerical form: -1^s * M * 2^E
- s : singed bit를 의미
- M: 보통 fractional value를 의미하고 [1.0, 2.0) == 1.xx 를 의미한다
- E: 2의 제곱수로 해당 값에 따라 소수점의 위치가 바뀐다.( 자리수를 의미 )
- Single Precision: 8 exp bit, 23 frac bits로 총 32bit에서 FP를 표현한 것 (FP32)
- Double Precision: 11 exp bit, 52 frac bits로 총 64bit에서 FP를 표현한 것 (FP64)
Normalized Values
Condition: exp ≠ 000....0 and exp ≠ 111....1
- E = Exp - Bias
- Exp: exp field에 의해 결정된 unsinged value
- Bias: Bias value
- 일반적으로 2^(K-1) -1 값을 사용
- Single precision의 경우 k = 8: 127
- Double precision의 경우 k = 11: 1023
- M = 1.xxx...x
- Minimum: frac = 000...0 (M = 1.0)
- Maximum: frac = 111...1 (M = 2.0 - ε)
Denormalized Values
Condition: exp = 000....0
Value
- Exponent value: E = 1 - Bias
- Significand value: M = 0.xxx...x
Case 1: exp = 000...0, frac = 000....0
- Represents value : 0.0
Case 2: exp = 000....0, frac ≠ 000....0
- 0에 매우 가까운 수를 의미
Special Values
condition: exp = 111...1
Case 1: exp = 111...1, frac = 000....0
- Represents value : 무한대 (infinity)
- overflows 발생한 operation을 의미함
Case 2: exp = 111....1, frac ≠ 000....0
- NaN(Not a Number)를 의미
- e.g. sqrt(-1) 등등
그 외에도
FP 16: Sign 1bit, exponent 5bits, fraction 10bits
BFP 16: Sign 1bit, exponent 8bits, fraction 7bits
같은 방식이 존재한다.
'Computer Architecture' 카테고리의 다른 글
Computer Architecture - Memory (3) (0) | 2024.12.30 |
---|---|
Computer Architecture - Memory (2) (1) | 2024.12.26 |
Computer Architecture - Memory (1) (1) | 2024.12.26 |
Computer Architecture - Pipeline (0) | 2024.12.26 |
Computer Architecture - Performance (0) | 2024.12.23 |