Arithmetic Logic Unit
The arithmetic logic unit, or ALU, is the digital circuit inside a processor that performs integer arithmetic and bitwise logic: addition, subtraction, AND, OR, XOR, NOT, shifts and rotates, and comparisons. It takes two input operands and an operation code, produces a result and a set of status flags, and has no memory of its own. If the CPU is the clerk following a list, the ALU is the calculator on the desk; it does not choose which sum to perform or fetch the numbers, but when handed two values and told which operation, it returns the answer within a fraction of a clock cycle.
An ALU is built entirely from logic gates, and its core is the adder. A one-bit full adder, made of XOR, AND and OR gates, adds two bits and a carry-in to give a sum and a carry-out; chaining them forms a multi-bit adder. A simple ripple-carry design waits for each carry to pass down the chain, which is slow at 32 or 64 bits, so real ALUs use faster schemes such as carry-lookahead that compute carries in parallel. Subtraction needs no separate circuit: in two's complement notation, invented to make signed numbers fit the same hardware, subtracting B is done by inverting its bits, adding one, and adding the result to A. The logic operations are even simpler, applying a gate to each pair of bits side by side.
The flags the ALU emits are how arithmetic turns into decisions. Four are nearly universal: zero (the result was all zeros), negative (the top bit is set), carry (an unsigned result did not fit) and overflow (a signed result did not fit). Comparing two numbers is done by subtracting them and discarding the difference but keeping the flags, and a conditional branch instruction then tests one of them, which is how every if statement and loop condition ends up. Because the width is fixed, results wrap around: an 8-bit unsigned value of 255 plus 1 becomes 0, and a signed 32-bit integer of 2,147,483,647 plus 1 becomes a large negative number, which is the cause of integer overflow bugs. The Ariane 5 rocket's failure in 1996 began with a 64-bit floating-point value being converted into a 16-bit signed integer that was too small to hold it.
The ALU has a defined place in the processor's division of labour, and what it does not do is as important as what it does. The control unit decides which operation the ALU performs and when, registers or memory supply the operands and keep the results, and the ALU itself neither fetches instructions nor stores anything. In the first computer designs of the 1940s it was called the central arithmetic part; the Intel 4004's ALU handled four bits at a time, whereas a modern core has several integer ALUs working in parallel so more than one operation can complete per clock. Floating-point arithmetic, vector (SIMD) operations and multiplication on a large scale are usually handled by separate execution units placed beside the integer ALUs.
In modern hardware the idea has been multiplied rather than replaced. A GPU contains thousands of simple ALUs organised to apply one operation to many values at once, and the "cores" in a GPU's marketing language are largely arithmetic units of this kind; AI accelerators extend the idea with arrays of multiply-accumulate units. For programmers the ALU explains why integer widths, signedness and shifts matter: why shifting an integer left by one place doubles it, why masks work, and why low-level bugs like unchecked overflow appear. A common misconception is that the ALU is "the brain" of the computer; it is a fast but obedient calculator driven by the control unit.
Read the ALU as the processor's calculator: it never decides what to compute, but given two values and an operation it produces the answer and a handful of flags that let the rest of the machine make decisions.