> For the complete documentation index, see [llms.txt](https://wiki.zacheller.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.zacheller.dev/hardware/nand2tetris/boolean-arithmetic-and-the-alu.md).

# Boolean Arithmetic and the ALU

**In a nutshell:** Using the chipset that we've built in the previous module, we will now proceed to build a family of *adders* -- chips designed to add numbers. We will then take a big step forward and build an *Arithmetic Logic Unit*. The ALU, which is designed to perform a whole set of arithmetic and logical operations, is the computer's calculating brain. Later in the course we will use this ALU as the centerpiece chip from which we will build the computer's *Central Processing Unit*, or CPU. Since all these chips operate on binary numbers (0's and 1's), we will start this module with a general overview of binary arithmetic, and only then delve into building the ALU.

**Key concepts:** Binary numbers, binary addition, the two's complement method, half-adders, full-adders, n-bit adders, counters, Arithmetic Logic Unit (ALU), combinational logic.

## Binary Numbers

![](/files/-MIMiMpxA2uaPVPrl-IV)

* What is the decimal value of 1101?
  * 1101(Binary) = 8+4+1(Decimal) = 13(Decimal)

## Binary Addition

![](/files/-MIMn1sXQ8xStods-9LG)

![](/files/-MIMnJf-mUt-v4wevuj_)

![](/files/-MIMnQRK83sFKx-1IqEk)

![](/files/-MIMnU8Gk61k2Tcuc3yf)

![](/files/-MIMncnZWbZMhXRNRd9l)

![](/files/-MIMnwxU_dpUucTFmE3u)

![](/files/-MIMnpPLDruFhpqULnRh)

## Negative numbers

![](/files/-MIMoZYpsW7wXObxyHow)

![](/files/-MIMpUCwc8NTu5KbqKNb)

![](/files/-MIMqBNwmKFDBGegojjH)

## Arithmetic Logic Unit

![](/files/-MIMrJpfHNGKMab_PZeP)

![](/files/-MIMrBELNWEa6a7O-1Ka)

![](/files/-MIMr5bAgJ-iL8jueRn1)

![](/files/-MIMsAKdVJZcc81yjM9P)

![](/files/-MIMt-NDNihI5327No9J)

## Project 2 Overview

![](/files/-MIMtLCQZaTnSq28LtSX)

![Sum: xor, Carry: and](/files/-MIMtSJ_FA2Aa7aTtYwf)

![Half adder is so named because it takes 2 to make a full adder](/files/-MIMu8mov2rI8IfTaVr9)

![](/files/-MIMwctL8IBSvVLrfVLI)

![](/files/-MIMySjAsaswmNH6V1xE)

![](/files/-MIMzW1EC16xPsBe3hEE)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wiki.zacheller.dev/hardware/nand2tetris/boolean-arithmetic-and-the-alu.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
