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 .
Where , , , etc.
IEEE 754 Floating-Point Formats
Floating point numbers are encoded into three parts: a Sign bit (), an Exponent (), and a Mantissa ().
The value evaluated is given by:
Single Precision (binary32): bits total. sign bit, exponent bits (bias ), and mantissa bits. Double Precision (binary64): bits total. sign bit, exponent bits (bias ), and 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 for single precision). Underflow: Occurs when a very small value normalizes to an exponent smaller than the minimum possible bound (e.g., 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., ).
◇Worked Examples
1. Binary to Decimal (Fractional)
Convert to decimal. Whole part: Fractional part:
Result: .
2. Decimal to Binary Float Conversion (IEEE Single Precision)
Convert to IEEE Single Precision floating point format.
- Determine Sign: Negative, so .
- Convert to Binary:
Whole:
Fractional:
Combined: - Normalize (Scientific Notation):
Shift the radix point left by to get .
The implicit leading is dropped. The mantissa (padded with zeros to bits). - Determine Exponent:
Base exponent is .
Add bias (): .
Convert to -bit binary: . - Final 32-bit String:
1 10000010 10000100000000000000000
In hexadecimal, this is .
3. Binary Float to Decimal
Evaluate the IEEE single precision string 0 01111101 11010000000000000000000 to decimal.
- Sign: Positive.
- Exponent: .
Unbias: . - Mantissa:
Add implicit : . - Evaluate Value:
Convert to decimal:
.
◇References & Navigation
- Previous Topic: ◇Data Representation - Integers
- Next Topic: ◇Data Representation - Characters and Boolean
- Related Notes: ◇Floating-Point Arithmetic Operations, ◇IEEE 754 Floating-Point Representation (Single & Double Precision)
ACTIVE RECALL VERIFICATION
Select an answer to verify conceptual comprehension and reveal the technical rationale.
Why is a fixed-point binary representation generally impractical for real numbers?
Which standard heavily defines the floating-point representations used in modern computer systems?
In floating-point notation, what does a truncation operation result in?
What is the positional weight of the first bit to the right of the radix point in a fractional binary number?
How many total bits does an IEEE 754 Single Precision (binary32) format utilize?
What are the three parts into which a floating-point number is encoded?
Under what condition does floating-point overflow occur?
What is the bias value used for the exponent in IEEE 754 Single Precision?
How is the mantissa (M) typically adjusted when normalizing a binary number into scientific notation?
What defines floating-point underflow?