> For the complete documentation index, see [llms.txt](https://cisco.microcisco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cisco.microcisco.com/icnd-1/untitled.md).

# Binary

Binary is a basic building block in networking. We use binary for IP addressing, sub-netting, access lists, inverse masks etc.

As someone said "There are 10 kinds of people in the world, those who understand binary and those that don't"\
All computers function by using a system of switches that can either be 'on' or 'off' being denoted by off=0 or on=1

### Binary vs Decimal

An analogy is 2 electrical cables. The cables can either have electricity run through them (ie "on" therefore = 1) of no current on them (ie "off = 0)\
As seen each cable has 2 states, either on or off.Therefore 2 cables with 2 states, the total amount of states is 2 x 2 =4 or $$2^2$$ \
00, 01, 10, 11 = off-off, of-on, on-off and on-on

Now, extending the above from 2 cables to 8 (this is because an IP address has 4 octets ( or four, eight bit values) 12345678.12345678.12345678.12345678

Looking at the first octet (8 bit value) the number of states that these 8 "cables" can be it would be 2x2x2x2x2x2x2x2 or $$2^8 = 256$$binary combinations

Lets do some maths\
$$2^0 = 1$$ \
$$2^1=2$$  \
$$2^2 = 4$$ \
$$2^3=8$$ \
$$2^4=16$$ \
$$2^5=32$$ \
$$2^6=64$$ \
$$2^7=128$$ \
$$2^8=256$$&#x20;

Decimal is a 10 Base System - 0 to 9\
Binary is a 2 Base System - 0 to 1

### A Famous Table:

![](https://4011257951-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtfmTuncdFr6DnNyt_b%2F-M0WT2LoIlRvp3Q8j-69%2F-M0Wc6Eb7AqyJ7Nav2Zd%2Fimage.png?alt=media\&token=1b443d25-24bf-4aea-bb02-e2d97350782e)

![If all 8 Cables was set to "ON" then the value would be 255](https://4011257951-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LtfmTuncdFr6DnNyt_b%2F-M0WT2LoIlRvp3Q8j-69%2F-M0WcOfG_h_9YtKfyeop%2Fimage.png?alt=media\&token=8f37294e-6fd8-4419-a872-a9510cc3e0ff)

An example from the above would be "What is the binary of the following decimal values:

| DECIMAL | BINARY   |
| ------- | -------- |
| 1       | 00000001 |
| 192     | 11000000 |
| 253     | 11111101 |

### IP Address Example

|         | OCTET 1   | OCTET 2  | OCTET3   | OCTET4   |
| ------- | --------- | -------- | -------- | -------- |
| DECIMAL | 172       | 16       | 60       | 5        |
| BINARY  | 101101100 | 00001000 | 00111100 | 00000101 |
