PROJECTENGRAM

DATA REPRESENTATION - REAL NUMBERS

5.0 Data Representation - Real Numbers

Tags: #◇Computer Science #◇CCICOMP #◇Problem Solving #◇M2


◇Overview

Real numbers contain both whole and fractional components. A fixed-point binary representation is generally impractical as it lacks the necessary range to represent very large numbers and the precision to represent very small numbers. Thus, computer systems utilize floating-point notation, based on binary scientific notation, to dynamically balance range and precision. Defined heavily by the IEEE 754 standard, floating-point representations often trade accuracy for range; truncation of exact mantissa bits results in stored values being close approximations rather than perfectly exact numbers.

◇Important Formulas

Fractional Binary Evaluation

The positional weight of bits to the right of the radix point uses negative powers of 22.
⋯+b−12−1+b−22−2+b−32−3+…\dots + b_{-1}2^{-1} + b_{-2}2^{-2} + b_{-3}2^{-3} + \dots
Where 2−1=0.52^{-1} = 0.5, 2−2=0.252^{-2} = 0.25, 2−3=0.1252^{-3} = 0.125, etc.

IEEE 754 Floating-Point Formats

Floating point numbers are encoded into three parts: a Sign bit (SS), an Exponent (E′E'), and a Mantissa (MM).
The value evaluated is given by:
Value=(−1)S×1.M×2E′−bias\text{Value} = (-1)^S \times 1.M \times 2^{E' - \text{bias}} Single Precision (binary32): 3232 bits total. 11 sign bit, 88 exponent bits (bias 127127), and 2323 mantissa bits. Double Precision (binary64): 6464 bits total. 11 sign bit, 1111 exponent bits (bias 10231023), and 5252 mantissa bits.

Range Limitations Overflow: Occurs when a value is too large and its normalized exponent exceeds the maximum possible bits (e.g., an exponent >127> 127 for single precision). Underflow: Occurs when a very small value normalizes to an exponent smaller than the minimum possible bound (e.g., <−126< -126 for single precision). Truncation: When a value has more significant digits than the mantissa capacity, the remaining least-significant bits are simply discarded, causing precision loss (e.g., 1/3=0.3333333…1/3 = 0.3333333\dots).

◇Worked Examples

1. Binary to Decimal (Fractional)

Convert 101.1012101.101_2 to decimal. Whole part: 1012=1(22)+0(21)+1(20)=4+0+1=5101_2 = 1(2^2) + 0(2^1) + 1(2^0) = 4 + 0 + 1 = 5 Fractional part: .1012=1(2−1)+0(2−2)+1(2−3)=0.5+0+0.125=0.625.101_2 = 1(2^{-1}) + 0(2^{-2}) + 1(2^{-3}) = 0.5 + 0 + 0.125 = 0.625
Result: 5.625105.625_{10}.

2. Decimal to Binary Float Conversion (IEEE Single Precision)

Convert −12.12510-12.125_{10} to IEEE Single Precision floating point format.

  1. Determine Sign: Negative, so S=1S = 1.
  2. Convert to Binary:
    Whole: 1210=1100212_{10} = 1100_2
    Fractional: 0.12510=0.00120.125_{10} = 0.001_2
    Combined: 1100.00121100.001_2
  3. Normalize (Scientific Notation):
    Shift the radix point left by 33 to get 1.1000012×231.100001_2 \times 2^3.
    The implicit leading 11 is dropped. The mantissa M=100001000000000000000002M = 10000100000000000000000_2 (padded with zeros to 2323 bits).
  4. Determine Exponent:
    Base exponent is 33.
    Add bias (127127): 3+127=1303 + 127 = 130.
    Convert 130130 to 88-bit binary: 10000010210000010_2.
  5. Final 32-bit String:
    1 10000010 10000100000000000000000
    In hexadecimal, this is C1420000h\text{C}1420000\text{h}.

3. Binary Float to Decimal

Evaluate the IEEE single precision string 0 01111101 11010000000000000000000 to decimal.

  1. Sign: 0  ⟹  0 \implies Positive.
  2. Exponent: 011111012=1251001111101_2 = 125_{10}.
    Unbias: 125−127=−2125 - 127 = -2.
  3. Mantissa: M=1101000…M = 1101000\dots
    Add implicit 11: 1.110121.1101_2.
  4. Evaluate Value:
    1.11012×2−2=0.01110121.1101_2 \times 2^{-2} = 0.011101_2
    Convert to decimal: 0(2−1)+1(2−2)+1(2−3)+1(2−4)+0(2−5)+1(2−6)0(2^{-1}) + 1(2^{-2}) + 1(2^{-3}) + 1(2^{-4}) + 0(2^{-5}) + 1(2^{-6})
    =0.25+0.125+0.0625+0.015625=0.45312510= 0.25 + 0.125 + 0.0625 + 0.015625 = 0.453125_{10}.

◇References & Navigation

CONFIRMATION // 理解度の確認

ACTIVE RECALL VERIFICATION

Select an answer to verify conceptual comprehension and reveal the technical rationale.

Q1

Why is a fixed-point binary representation generally impractical for real numbers?

Q2

Which standard heavily defines the floating-point representations used in modern computer systems?

Q3

In floating-point notation, what does a truncation operation result in?

Q4

What is the positional weight of the first bit to the right of the radix point in a fractional binary number?

Q5

How many total bits does an IEEE 754 Single Precision (binary32) format utilize?

Q6

What are the three parts into which a floating-point number is encoded?

Q7

Under what condition does floating-point overflow occur?

Q8

What is the bias value used for the exponent in IEEE 754 Single Precision?

Q9

How is the mantissa (M) typically adjusted when normalizing a binary number into scientific notation?

Q10

What defines floating-point underflow?

Data Representation - Real Numbers | PROJECT ENGRAM