Computer Basics - Arithmetic Logic Unit

What Is an Arithmetic Logic Unit (ALU)?

The Arithmetic Logic Unit (ALU) is a core component of the CPU (Central Processing Unit). It is responsible for performing all arithmetic and logical operations in a computer.

Think of it as the “calculator” of the CPU — it handles the actual computation.

Main Functions of the ALU

1. Arithmetic Operations

  • These include basic mathematical operations such as:

    • Addition

    • Subtraction

    • Multiplication

    • Division

2. Logical Operations

  • These involve decision-making and comparisons, such as:

    • AND

    • OR

    • NOT

    • XOR

    • Comparisons (e.g., greater than, less than, equal to)

3. Bitwise Operations

  • Operations that work on individual bits of binary numbers.

    • Example: Shifting bits left or right

How the ALU Works

  • The ALU receives data (operands) and instructions from the Control Unit.

  • It performs the operation and sends the result back to the CPU registers or memory.

Importance of the ALU

  • It is essential for all types of computing tasks, from simple math in a calculator app to complex algorithms in scientific computing.

  • Every operation a program runs that involves logic or math goes through the ALU.

Simple Example

If you type 5 + 3 into a calculator:

  1. The Control Unit sends the numbers and the operation (+) to the ALU.

  2. The ALU performs the addition.

  3. The result (8) is sent back to be displayed as output.