---
# System prepended metadata

title: Logic Gates

---

# Logic Gates

([home](https://github.com/alexhkurz/introduction-to-numbers/blob/master/README.md) ... [previous](https://hackmd.io/@alexhkurz/HyzjN3qsI) ... [next](https://hackmd.io/@alexhkurz/SyJCHSMs8))

The addition and multiplication of the field with two numbers are famous in logic and computer hardware. They are two important examples of logic gates. 

To read the tables in a logical way think of `0` as False or No and of `1` as True or Yes.


|XOR|0| 1|
|:---:|:---:|:---:|
| 0 | 0| 1|
| 1 | 1| 0|
		
`XOR` is short for exclusive or. You see from the table that if `A XOR B` is True not both `A` and `B` can be true (thus, `A` and `B` exclude each other).

|AND|0| 1|
|:---:|:---:|:---:|
| 0 | 0| 0|
| 1 | 0| 1|

One way to think about `XOR` and `AND` is in terms of a question and answer game. 

Let `Q1?` and `Q2?` be two questions. Then you can form new questions

    Q1 XOR Q2?
    
and 

    Q1 AND Q2?
    
You answer Yes to `Q1 XOR Q2?` if and only if you answer exactly one of `Q1` or `Q2` with yes.

You answer Yes to `Q1 AND Q2?` if and only if you answer Yes to both`Q1` and `Q2`.

**Activity:** Think of concrete questions that illustrate `XOR` and `AND`.

Logic gates are important since they are used to build computer hardware.

Let us look at an example.

**Activity:** Suppose we already know how to implement `XOR` and `AND` in hardware. Can we build a circuit that adds two bits?

**Optional Activity:** Can you build a circuit that adds to binary two-digit numbers? 
