# Binary

Binary, or the base 2 numeral system, is a system of noting down numbers only using 0 and 1 (unlike the 0 - 9 of our, decimal system). A digit which can only have the value of 0 or 1 is boolean.

Decimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9... 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, [...] 98, 99... 100, 101, 102, 103...

Binary: 0, 1... 10, 11... 100, 101, 110, 111... 1000

All home computers store their data in binary notation, as it is the simplest and cheapest method. A single unit of data that holds this value in a computer is a bit. An 8-bit computer, for example, deals with 8 digits of data (00000000 - 11111111), which can represent 256 different values - this is why such computers have this limit set on amount of the color palette and other things.

0 0 0 0 0 0 0 0
| | | | | | | |
amount:128 64 32 16 8 4 2 1

Example reading of binary number 101010:

1 0 1 0
| | | |
amount: 8 + 0 + 2 + 0 = 10

## Two's complement

A system of encoding numbers in binary that incorporates negative numbers.

000 001 010 011 100 101 110 111
0 1 2 3 4 5 6 7 - unsigned
0 1 2 3 -4 -3 -2 -1 - two's complement