엔지니어가 되고 싶은 공돌이
03. Representation of Floating Points 본문
3. 1. Fixed Point Number
- sign, integer, fractional 3개의 part로 나누어서 수를 저장합니다.
- sign bit가 0이면 양수를, 1이면 음수를 표현하고,
integer part로 소수점 앞부분의 수를 2진수로 표현하며,
fractional part로 소수점 뒷부분의 수를 2진수로 표현합니다.
ex) sign 1 bit / interger 3 bit / fractional 4 bit 라고 가정하면,
5.625 -> 0 101 1010 로 표현합니다.
- Pros: 간단하고, Floating Point Hardware가 필요없고, Low cost Embedded Processors에서 사용.
- Cons: Cannot represent wide ranges of numbers.
3. 2. Floating Point Number
- IEEE Standard 754, Supported by all major CPUs.
- Normalized Form: ± 1.xxx…2 X 2yy….
- Single Precision(32bit): sign 1bit / Exponent 8bit / Mantissa 23bit / bias 127.
- Double Precision(64bit): sign 1bit / Exponent 11bit / Mantissa 52bit / bias 1023.
- MSB가 sign bit가 되며, Positive Number이면 0을, Negative Number이면 1을 넣습니다.
- 2진수를 Normalized한 후, 2yy… 에서 yy… 를 bias에 더해서 Exponent에 저장합니다.
Exponent = bias + yy… .
- 1.xxx… 에서 xxx… 을 그대로 Mantissa에 저장합니다.
- Exponent = 00 … 00, Mantissa = 00 … 00 -> 0.
- Exponent = 00 … 00, Mantissa ≠ 00 … 00 -> Numbers very close to 0.0.
- Exponent = 11 … 11, Mantissa = 00 … 00 -> ∞.
- Exponent = 11 … 11, Mantissa ≠ 00 … 00 -> NaN(Not a Number).
- int를 Floating Point로 바꿀 때 float형은 정확한 값을 못 나타낼 수 도 있으므로, double 형을 사용합니다.
'Computer Science > System Programming' 카테고리의 다른 글
06. Assembly 1: Basic Operations (0) | 2025.02.06 |
---|---|
05. Program and Instruction Set (0) | 2025.02.06 |
04. Byte Ordering (0) | 2025.02.05 |
02. Representation of Integer (0) | 2025.02.03 |
01. Digital Systems (0) | 2025.02.03 |