Skip to content

Unit 1 — Number Systems

Unit Overview (click to expand) Welcome to Unit 1 of Digital System Design, where we explore the number systems that form the mathematical backbone of every digital device you use. You already think in decimal every day — base ten, with digits zero through nine — but computers speak an entirely different language. Understanding how to move between that familiar world and the world of ones and zeros is where your journey into digital design truly begins. Let's start with the big idea: positional notation. In any number system, the value of a digit depends on its position. In decimal, the number 365 means three hundreds, six tens, and five ones. The same principle applies in binary, octal, and hexadecimal — only the base changes. Binary uses base two with just the digits zero and one. Octal uses base eight with digits zero through seven. And hexadecimal uses base sixteen, borrowing the letters A through F to represent values ten through fifteen. So how do you convert between them? The key techniques are repeated division for converting from decimal to another base, and weighted expansion for converting back to decimal. With a little practice, you will also learn shortcut groupings — every three binary digits map neatly to one octal digit, and every four binary digits map to one hexadecimal digit. Once you are comfortable moving between bases, we turn to binary arithmetic — addition, subtraction, and the critical concept of signed versus unsigned representation. Two's complement lets us represent both positive and negative integers using a fixed number of bits, and the beauty is that the same addition circuitry works for both signed and unsigned values. **Key Takeaways** 1. Positional notation is the unifying principle behind decimal, binary, octal, and hexadecimal — only the base differs. 2. Conversion techniques such as repeated division, weighted expansion, and binary-to-hex grouping are essential everyday skills in digital design. 3. Two's complement representation enables signed arithmetic with the same hardware used for unsigned addition, and overflow detection tells you when a result has exceeded the available bit width.

Summary

Number systems form the mathematical foundation of digital system design, providing the essential framework for representing and manipulating information in electronic circuits. This unit introduces the four primary number systems used in computing—decimal, binary, octal, and hexadecimal—and establishes the concepts of positional notation that underpin all digital arithmetic operations. Students will master conversion techniques between bases, perform binary arithmetic, and understand the critical distinction between signed and unsigned number representations. The unit culminates with two's complement arithmetic, the dominant method used in modern processors for handling negative numbers, along with techniques for detecting arithmetic overflow conditions.

Concepts Covered

  1. Digital Systems
  2. Analog vs Digital Signals
  3. Binary Number System
  4. Decimal Number System
  5. Octal Number System
  6. Hexadecimal Number System
  7. Positional Notation
  8. Base of Number System
  9. Radix Point
  10. Bit
  11. Nibble
  12. Byte
  13. Word
  14. Most Significant Bit
  15. Least Significant Bit
  16. Binary to Decimal Conversion
  17. Decimal to Binary Conversion
  18. Octal to Decimal Conversion
  19. Decimal to Octal Conversion
  20. Hexadecimal to Decimal
  21. Decimal to Hexadecimal
  22. Binary to Octal Conversion
  23. Octal to Binary Conversion
  24. Binary to Hexadecimal
  25. Hexadecimal to Binary
  26. Binary Addition
  27. Binary Subtraction
  28. Binary Multiplication
  29. Binary Division
  30. Signed Numbers
  31. Unsigned Numbers
  32. Sign Magnitude
  33. Ones Complement
  34. Twos Complement
  35. Sign Extension
  36. Twos Complement Addition
  37. Twos Complement Subtraction
  38. Overflow Detection
  39. Underflow
  40. Range of Signed Numbers

Prerequisites

Before beginning this unit, students should have:

  • Basic algebra and mathematical reasoning skills
  • Familiarity with the decimal number system and place values
  • Understanding of basic arithmetic operations (addition, subtraction, multiplication, division)

1.1 Introduction to Digital Systems

Modern computing relies entirely on digital systems — electronic circuits that process information using discrete signal levels rather than continuous values. Unlike analog signals, which can take any value within a continuous range (like the smooth variation of audio from a microphone), digital signals represent information using only two distinct states: typically high voltage (logic 1) and low voltage (logic 0).

This binary representation offers significant advantages for electronic systems. Digital circuits exhibit superior noise immunity because small variations in voltage do not change the logical interpretation of a signal. Additionally, digital information can be stored, copied, and transmitted without degradation, enabling the complex computations that power everything from smartphones to supercomputers.

Signal Type Values Example Noise Immunity
Analog Continuous Audio waveform Low
Digital Discrete (0, 1) Binary data High

The foundation of all digital systems is the binary number system, which uses only two symbols (0 and 1) to represent numerical values. Understanding how numbers are encoded in binary — and how to convert between binary and other number systems — is essential for digital system design.

Diagram: Analog vs Digital Signal Comparison


1.2 Positional Number Systems

All the number systems used in digital design — decimal, binary, octal, and hexadecimal — are positional number systems. In positional notation, the value of each digit depends on both the digit itself and its position within the number. The base (also called radix) determines how many unique symbols the system uses and the multiplier for each position.

The general formula for positional notation is:

\[N = \sum_{i=-m}^{n-1} d_i \times \text{base}^i\]

where \(d_i\) represents the digit at position \(i\), \(n\) is the number of integer digits, and \(m\) is the number of fractional digits. The radix point (decimal point in base 10, binary point in base 2) separates integer positions from fractional positions.

The Decimal Number System

The decimal number system (base 10) uses ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Each position represents a power of 10, with the rightmost integer position being \(10^0 = 1\).

Example — Decimal Positional Expansion

\[472_{10} = 4 \times 10^2 + 7 \times 10^1 + 2 \times 10^0 = 400 + 70 + 2\]

The Binary Number System

The binary number system (base 2) uses only two symbols: 0 and 1. This maps directly to the two voltage states in digital circuits, making binary the native language of computers. Each position represents a power of 2.

Example — Binary to Decimal Conversion

\[1011_2 = 1 \times 2^3 + 0 \times 2^2 + 1 \times 2^1 + 1 \times 2^0 = 8 + 0 + 2 + 1 = 11_{10}\]

The Octal Number System

The octal number system (base 8) uses eight symbols: 0 through 7. Octal provides a convenient shorthand for binary because each octal digit corresponds exactly to three binary digits. While less common today than hexadecimal, octal appears in Unix file permissions and some assembly language contexts.

The Hexadecimal Number System

The hexadecimal number system (base 16) uses sixteen symbols: 0–9 and A–F. Each hexadecimal digit corresponds to exactly four binary digits, making it the preferred shorthand for binary data in modern computing. Memory addresses, color codes, and machine code are typically displayed in hexadecimal.

Hex Symbol Mapping

A = 10    B = 11    C = 12    D = 13    E = 14    F = 15

Base Name Symbols Binary Digits per Symbol
2 Binary 0, 1 1
8 Octal 0-7 3
10 Decimal 0-9
16 Hexadecimal 0-9, A-F 4

Diagram: Positional Notation Interactive Explorer


1.3 Binary Data Units

Digital systems organize binary digits into standard groupings that facilitate data storage and manipulation. Understanding these units is essential for working with computer memory and data transfer.

  • Bit (binary digit) — the fundamental unit of digital information, representing a single 0 or 1. The term combines "binary" and "digit." While a single bit can only represent two states, combining multiple bits exponentially increases representational capacity.
  • Nibble — consists of 4 bits and can represent \(2^4 = 16\) distinct values (0–15 in decimal, or 0–F in hexadecimal). Each hexadecimal digit corresponds to exactly one nibble, which is why hex is so useful for representing binary data.
  • Byte — comprises 8 bits (2 nibbles) and represents \(2^8 = 256\) distinct values (0–255 unsigned). The byte is the standard addressable unit of memory in most computer architectures and commonly represents a single character in ASCII encoding.
  • Word — a processor-specific unit representing the natural data size for a particular architecture. Modern 64-bit processors use 64-bit (8-byte) words, while older 32-bit systems use 32-bit (4-byte) words. Word size affects memory addressing, register width, and arithmetic precision.
Unit Bits Values Common Use
Bit 1 2 Single logic state
Nibble 4 16 One hex digit
Byte 8 256 Character, memory address unit
Word 32/64 4B/16E Processor native unit

Within any binary number, we identify positions by significance. The Most Significant Bit (MSB) is the leftmost bit, contributing the largest value to the number. The Least Significant Bit (LSB) is the rightmost bit, contributing the smallest value (either 0 or 1). In signed number representations, the MSB often indicates the sign.

Memory Size Prefixes

In computing, size prefixes have two conventions: decimal (SI) where 1 KB = 1,000 bytes, and binary (IEC) where 1 KiB = 1,024 bytes. Hardware specifications typically use binary prefixes, while storage manufacturers often use decimal prefixes.


1.4 Base Conversion Methods

Converting between number systems is a fundamental skill in digital design. Different methods are optimal for different conversion types.

Decimal to Binary Conversion

The repeated division method converts decimal integers to binary by repeatedly dividing by 2 and recording the remainders. The binary result is formed by reading the remainders from last to first.

Example — Convert \(19_{10}\) to Binary

Step Quotient ÷ 2 Remainder
1 19 9 1 (LSB)
2 9 4 1
3 4 2 0
4 2 1 0
5 1 0 1 (MSB)

Reading remainders bottom-to-top: \(19_{10} = 10011_2\)

Binary to Decimal Conversion

To convert binary to decimal, multiply each bit by its positional power of 2 and sum the results.

Example — Convert \(10011_2\) to Decimal

\[\begin{aligned} 10011_2 &= 1 \times 2^4 + 0 \times 2^3 + 0 \times 2^2 + 1 \times 2^1 + 1 \times 2^0 \\ &= 16 + 0 + 0 + 2 + 1 = 19_{10} \end{aligned}\]

Hexadecimal Conversions

Decimal to hexadecimal uses repeated division by 16. Hexadecimal to decimal uses positional notation with powers of 16.

Example — Convert \(255_{10}\) to Hexadecimal

  • \(255 \div 16 = 15\) remainder \(15\) (F)
  • \(15 \div 16 = 0\) remainder \(15\) (F)

Result: \(255_{10} = \text{FF}_{16}\)

Octal Conversions

Decimal to octal uses repeated division by 8. Octal to decimal uses positional notation with powers of 8.

Binary-Octal-Hexadecimal Shortcuts

Because 8 = 2³ and 16 = 2⁴, direct conversions between binary and octal/hexadecimal are straightforward:

  • Binary ↔ Octal: Group binary digits in sets of 3 (from the radix point outward), converting each group to its octal equivalent
  • Binary ↔ Hexadecimal: Group binary digits in sets of 4, converting each group to its hex equivalent

Example — Convert \(10111010_2\) to Hexadecimal

Group in fours: \(1011 \ 1010\)
Convert each group: \(\text{B} \ \text{A}\)
Result: \(10111010_2 = \text{BA}_{16}\)

Diagram: Base Conversion Calculator


1.5 Binary Arithmetic Operations

Digital computers perform all arithmetic in binary. Understanding binary arithmetic operations is essential for comprehending how processors execute calculations.

Binary Addition

Binary addition follows the same principles as decimal addition but with only two digits. The addition rules are:

  • \(0 + 0 = 0\)
  • \(0 + 1 = 1\)
  • \(1 + 0 = 1\)
  • \(1 + 1 = 10\) (0 with carry 1)
  • \(1 + 1 + 1 = 11\) (1 with carry 1)

Example — Add \(1011_2 + 1101_2\)

    1 1 1 1    (carries)
      1 0 1 1
    + 1 1 0 1
    ---------
    1 1 0 0 0

Result: \(1011_2 + 1101_2 = 11000_2\) (11 + 13 = 24 in decimal)

Binary Subtraction

Binary subtraction can be performed directly using the rules:

  • \(0 - 0 = 0\)
  • \(1 - 0 = 1\)
  • \(1 - 1 = 0\)
  • \(0 - 1 = 1\) with borrow

Example — Subtract \(1101_2 - 1001_2\)

      1 1 0 1
    - 1 0 0 1
    ---------
      0 1 0 0

Result: \(1101_2 - 1001_2 = 0100_2\) (13 - 9 = 4 in decimal)

In practice, digital systems typically perform subtraction using two's complement addition, eliminating the need for separate subtraction hardware.

Binary Multiplication

Binary multiplication is simpler than decimal multiplication because each partial product is either 0 (multiplied by 0) or the multiplicand itself (multiplied by 1), shifted appropriately.

Example — Multiply \(101_2 \times 11_2\)

        1 0 1
      ×   1 1
      -------
        1 0 1    (101 × 1)
      1 0 1      (101 × 1, shifted left)
      -------
      1 1 1 1

Result: \(101_2 \times 11_2 = 1111_2\) (5 × 3 = 15 in decimal)

Binary Division

Binary division uses the same long division algorithm as decimal division, but comparisons and subtractions are simpler with only 0 and 1 as possible quotient digits.

Example — Binary Division

          1 1 1 1 1 0
        -------------
  1 0 ) 1 1 1 1 1 0 0
        1 0
        ---
          1
            ↓
          1 1
          1 0
          ---
            1
              ↓
            1 1
            1 0
            ---
              1
                ↓
              1 1
              1 0
              ---
                1
                  ↓
                1 0
                1 0
                ---
                  0
                    ↓
                  0 0
                    0     ← remainder
Binary Decimal
Dividend \(1111100_2\) 124
Divisor \(10_2\) 2
Quotient \(111110_2\) 62
Remainder 0 0

Diagram: Binary Arithmetic Practice


1.6 Signed Number Representations

Digital systems must represent both positive and negative numbers. Several encoding schemes exist, each with distinct characteristics. The three primary methods are sign-magnitude, one's complement, and two's complement.

Unsigned Numbers

Unsigned numbers represent only non-negative values. For an n-bit unsigned number, the range is \(0\) to \(2^n - 1\). All bits contribute to the magnitude.

Bits Unsigned Range Values
4 0 to 15 16
8 0 to 255 256
16 0 to 65,535 65,536
32 0 to 4,294,967,295 4.29B

Sign-Magnitude Representation

In sign-magnitude representation, the MSB indicates the sign (0 = positive, 1 = negative), and the remaining bits represent the magnitude. This mirrors how humans write signed numbers.

Example — 4-bit Sign-Magnitude

  • \(+5 = 0101\)
  • \(-5 = 1101\)

Sign-magnitude has two representations of zero (\(+0 = 0000\), \(-0 = 1000\)), which complicates hardware design. Addition and subtraction require separate logic, making this representation inefficient for arithmetic circuits.

One's Complement Representation

One's complement represents negative numbers by inverting all bits of the positive equivalent. The MSB still indicates sign.

Example — 4-bit One's Complement

  • \(+5 = 0101\)
  • \(-5 = 1010\) (invert all bits of 0101)

One's complement also has two zeros (\(+0 = 0000\), \(-0 = 1111\)) and requires end-around carry for correct addition results.

Two's Complement Representation

Two's complement is the dominant representation in modern digital systems. To find the two's complement of a number, invert all bits and add 1. Alternatively, find the one's complement and add 1.

Example — 4-bit Two's Complement

  • \(+5 = 0101\)
  • \(-5\): Invert \(0101 \rightarrow 1010\), add 1 \(\rightarrow 1011\)

Two's complement has a single representation of zero and allows addition and subtraction to use the same hardware. The range for n-bit two's complement is \(-2^{n-1}\) to \(2^{n-1} - 1\).

Bits Two's Complement Range
4 -8 to +7
8 -128 to +127
16 -32,768 to +32,767
32 -2,147,483,648 to +2,147,483,647

Diagram: Signed Number Representation Comparison


1.7 Two's Complement Arithmetic

Two's complement enables addition and subtraction using identical hardware, which is why it dominates in processor design.

Two's Complement Addition

Two's complement addition works identically to unsigned binary addition. The key insight is that the representation automatically handles signed arithmetic — simply add the bit patterns and discard any carry out of the MSB.

Example — Add \(5 + (-3)\) in 4-bit Two's Complement

  • \(+5 = 0101\)
  • \(-3 = 1101\) (two's complement of 3)
    1 1 1      (carries)
      0 1 0 1
    + 1 1 0 1
    ---------
    1 0 0 1 0

Discard the carry: Result = \(0010 = +2\)

Two's Complement Subtraction

Two's complement subtraction is performed by adding the two's complement of the subtrahend:

\[A - B = A + (-B) = A + \overline{B} + 1\]

Example — Calculate \(3 - 5\) in 4-bit Two's Complement

  • \(+3 = 0011\)
  • \(+5 = 0101\), so \(-5 = 1011\)
  • \(3 + (-5) = 0011 + 1011 = 1110 = -2\)

Sign Extension

When operations require operands of different bit widths, sign extension preserves the numerical value by replicating the sign bit. For positive numbers (MSB = 0), extend with 0s; for negative numbers (MSB = 1), extend with 1s.

Example — Extend 4-bit \(1101\) (-3) to 8 bits

\[1101 \rightarrow 11111101\]

Both represent \(-3\) in two's complement.


1.8 Overflow and Underflow Detection

Arithmetic operations can produce results that exceed the representable range. Overflow occurs when the result is too large (positive) for the bit width; underflow occurs when the result is too small (negative).

Detecting Overflow in Two's Complement

Overflow occurs when:

  • Adding two positive numbers yields a negative result
  • Adding two negative numbers yields a positive result

Mathematically, overflow is detected when the carry into the MSB differs from the carry out of the MSB:

\[\text{Overflow} = C_{in,MSB} \oplus C_{out,MSB}\]

Example — Add \(+7 + (+3)\) in 4-bit Two's Complement

  • \(+7 = 0111\)
  • \(+3 = 0011\)
    0 1 1 1    (carries: Cin to MSB = 1)
      0 1 1 1
    + 0 0 1 1
    ---------
      1 0 1 0  (Cout from MSB = 0)

Result: \(1010 = -6\) (incorrect!)
Overflow detected: \(C_{in} = 1\), \(C_{out} = 0\), so \(1 \oplus 0 = 1\) (overflow)

The correct result (+10) cannot be represented in 4 bits, which can only hold -8 to +7.

Range of Signed Numbers

For an n-bit two's complement number:

  • Minimum value: \(-2^{n-1}\) (e.g., \(-8\) for 4 bits: \(1000\))
  • Maximum value: \(2^{n-1} - 1\) (e.g., \(+7\) for 4 bits: \(0111\))
  • Total values: \(2^n\)

Overflow Detection is Critical

Undetected overflow can cause catastrophic failures in safety-critical systems. The 1996 Ariane 5 rocket explosion was caused by a 64-bit to 16-bit conversion overflow in the guidance system.

Diagram: Overflow Detection Simulator


1.9 Practical Applications

Number systems and binary arithmetic form the foundation for all digital hardware. Understanding these concepts is essential for:

Where These Concepts Apply

  • Memory addressing: Addresses are binary numbers, typically displayed in hexadecimal
  • Processor arithmetic: ALUs implement binary addition with overflow detection
  • Color encoding: RGB colors use 8-bit unsigned values (0–255) per channel
  • Network protocols: IP addresses, MAC addresses, and packet headers use binary/hex
  • Embedded systems: Sensor data, actuator control, and register manipulation require binary operations

Common Pitfalls

  • Forgetting to include carry bits in multi-byte arithmetic
  • Mixing signed and unsigned interpretations of the same bit pattern
  • Sign extension errors when widening values
  • Overflow in intermediate calculations even when final result would fit
  • Off-by-one errors in range calculations

Diagram: Number Systems Concept Map


Summary and Key Takeaways

This unit established the mathematical foundation for digital system design through the following key concepts:

  • Digital systems use discrete binary signals (0 and 1) rather than continuous analog values, providing noise immunity and reliable computation.
  • Positional notation is the basis for all number systems used in computing. The value of each digit depends on its position and the base of the system.
  • Four number systems are commonly used: decimal (base 10) for human readability, binary (base 2) for hardware implementation, octal (base 8) and hexadecimal (base 16) as compact binary representations.
  • Binary data units include bits (1), nibbles (4), bytes (8), and words (32/64), with MSB and LSB identifying the most and least significant positions.
  • Base conversions use repeated division (decimal to other bases), positional expansion (other bases to decimal), or direct grouping (binary ↔ octal/hex).
  • Binary arithmetic follows the same algorithms as decimal but with only two digits. Carries and borrows propagate similarly to decimal.
  • Signed number representations include sign-magnitude, one's complement, and two's complement. Two's complement dominates because it has a unique zero and allows addition/subtraction with the same hardware.
  • Overflow detection is critical for correct arithmetic. In two's complement, overflow occurs when the carry into the MSB differs from the carry out of the MSB.

Self-Check Questions

What is the range of an 8-bit two's complement number?

The range is \(-128\) to \(+127\) (i.e., \(-2^7\) to \(2^7 - 1\)).

Why is two's complement preferred over sign-magnitude?

Two's complement has a single representation of zero and allows addition and subtraction to use identical hardware, simplifying processor design.

Convert \(\text{A3}_{16}\) to binary.

\(\text{A} = 1010\), \(3 = 0011\), so \(\text{A3}_{16} = 10100011_2\).


Interactive Walkthrough

Step through a complete base conversion problem with animated visuals:


Take the Unit Quiz | See Annotated References