Binary Basics

The number system that we all know and use every day is called Decimal. In decimal we have digits from 0 to 9 which can use in an combination to represent any value.

Binary is also a number system where we have two digits, 0 and 1, which we also use to represent a value or quantity.

Counting

We all know how to count in decimal but how does counting look like in binary?

0, 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1111, 10000

The counting rules are the same for both number systems:

1. Increase the right side by one until you run out of digits

2. Increase left side and continue with the first step

Conversion

To be able to convert binary to decimal we can use this mapping:

1 1 1 1 1 1 1 1
128 64 32 16 8 4 2 1

To convert binary to decimal we will add the lower row numbers where ever there is a 1 in the upper row.

So binary 11111111 is decimal 255.
Binary 00000001 is decimal 1.

Bits and Bytes

A bit is one binary digit i.e. 0 or 1. A byte is 8 bits. A byte used to be the number of bits used to encode one character of text.

Use case

One popular use case of binary is IP addresses.  Every IP address consists of 4 numbers divided by dots. You will never see one of those numbers bigger than 255 or smaller than 0. That's because each part of the IP consists of 8 bits (Octet). The highest number you can get from 8 bits is 255.

Adnan M.

Adnan M.