Number Systems

Computer Organization and Digital Design 2nd Semester

Basic Definitions

Number Bases

  • Binary (Base 2): Uses digits 0, 1
  • Octal (Base 8): Uses digits 0-7
  • Decimal (Base 10): Uses digits 0-9
  • Hexadecimal (Base 16): Uses digits 0-9, A-F

Key Concepts

  • Positional Number System: Each digit’s value depends on its position
  • Multiple Representations: Same binary pattern can represent different values depending on the number system used
    • Example: could be 10, -2, -5, or -6

Base Conversions

Binary to Decimal

Use positional notation:

Binary to Octal

Group binary digits in sets of 3 (from right):

Binary to Hexadecimal

Group binary digits in sets of 4 (from right):

Other Examples

Negative Binary Numbers

Three Main Approaches

  1. Sign-and-Magnitude
  2. Ones’-Complement
  3. Two’s-Complement

Common Features

  • MSB (Most Significant Bit) is the sign bit:
    • 0 = Positive
    • 1 = Negative

Two’s-Complement (Preferred Method)

  • Advantages:
    • Widely used in modern systems
    • Simplifies arithmetic operations
    • Only one representation for zero
  • Process: To get negative of a number:
    1. Invert all bits (ones’-complement)
    2. Add 1 to the result

Binary Numbers with Decimals

Fractional Binary Representation

  • Uses negative powers of 2 for digits after the binary point
  • Example:

Converting Decimal Fractions to Binary

Method: Multiply by 2, take integer part, repeat with fractional part

  • Example: Convert to binary
    • → 0
    • → 1
    • → 1
    • Result:

Limitations

  • Some decimal fractions cannot be exactly represented in binary
  • Example: (repeating)
  • This leads to precision issues in computer calculations

Floating Point Numbers

IEEE 754 Standard

The most common floating point representation:

Single Precision (32-bit)

SignExponentMantissa/Significand
1823

Double Precision (64-bit)

SignExponentMantissa/Significand
11152

Components

  1. Sign Bit: 0 for positive, 1 for negative
  2. Exponent: Biased representation (actual exponent + bias)
    • Single: bias = 127
    • Double: bias = 1023
  3. Mantissa: Fractional part (normalized, implicit leading 1)

Formula

Special Values

  • Zero: Exponent = 0, Mantissa = 0
  • Infinity: Exponent = all 1s, Mantissa = 0
  • NaN (Not a Number): Exponent = all 1s, Mantissa ≠ 0
  • Denormalized: Exponent = 0, Mantissa ≠ 0

Example

Single precision representation of :

  1. Convert to binary:
  2. Normalize:
  3. Sign: 0 (positive)
  4. Exponent:
  5. Mantissa:

A/D and D/A Conversion

  • Real-world signals: Continuous/analog form
  • Digital systems: Model these as 0s and 1s
  • Conversion needed: Between analog and digital representations