### Introduction

Bits and bytes are the fundamental components that form the basis of the `binary system`

. This system is used in most of computing applications in our world! From your calculator, laptop, to rocket and space communication. You may have heard of the term `quantum computing`

, which aims to go beyond the limitation of `binary system`

… Well…that is for the future, let’s take a look at the binary system that builds the world we know today.

### Bits and Bytes

- A
`bit`

is the smallest unit of data in computing, representing a binary digit that can be either a 0 or a 1 (2 possible states, therefore the name`binary system`

). - A
`byte`

, on the other hand, is a group of 8`bits`

.

**For example:**

- 1 bit has 2 possible combinations: 0 or 1.
- 2 bits have 4 possible combinations: 00, 01, 10, 11.
- 3 bits have 8 possible combinations: 000, 001, 010, 011, 100, 101, 110, 111.
- 1 byte has 8 bits, which have 256 possible combinations: 00000000, 00000001, 00000010 … etc.
- 2 bytes have 16 bits, which have 65535 possible combinations.

### Different Units of Measurements in Binary System

Like the `metric system`

, binary system also uses international `System of Units`

(SI) to represent a bit or byte value in different magnitudes: kilo, mega, giga, tera are quite common. Depending on the application, we use different units to measure different things:

#### Data **Storage**

We normally use `byte`

to represent data storage size. For example, a file’s size or USB drive’s capacity are often represented in number of `bytes`

.

- 1KB (kilobyte) => 1024 bytes
- 1MB (Megabyte) => 1024 kilobytes
- 1GB (Gigabyte) => 1024 megabytes
- 1TB (Terabyte) => 1024 gigabytes

#### Transfer Speed

We use `byte per second`

to represent data transfer speeds. For example, when you copy a large file from your Windows 10 to a USB drive, a window will pop up to show you the speeds in `byte per second`

and how many seconds left.

- 1 KB/s (Kilobyte per second) => 1024 bytes /s
- 1 MB/s (Megabyte per second) => 1024 kilobytes / s
- 1 GB/s (Gigabyte per second) => 1024 Megabyte / s

#### Network Throughput

We normally use `bits per second`

to represent throughput. For example, when you are shopping for home internet, your speed option is often represented in `bits per second`

.

- 1Kbps (Kilobit per second) => 1024 bits / s
- 1Mbps (Megabit per second) => 1024 kilobits / s
- 1Gbps (Gigabit per second) => 1024 megabits / s

### Decimal and Binary System

Why is 1 kilo equals to 1024 but not 1000? The answer is “it depends”.

In the real world, our numbering system bases on the international `system of units`

, which uses the decimal number system (base 10), which means:

- 1K: 1000
- 1M: 1000K
- 1G: 1000M

Computers, on the other hand, use the binary system (base 2), which means:

- 1K: 1024
- 1M: 1024K
- 1G: 1024M

### The Missing GBs in my USB Drive?

Knowing the difference between the binary and the decimal system, can you tell me where my missing GBs of data go? I purchased a new hard drive rated at 1TB, connected to my computer, but it only shows 952 GB instead of 1 TB.

In fact, there is no missing GBs in my new hard drive. It is just the difference in data representation:

- I purchased a 1 TB hard drive measured in the decimal system, which equals 1000 GBs,
- I connected this hard drive to my computer.
- My computer uses the binary system, so it recognized 1 TB (in decimal) as 952 GB (in binary)
- There is no missing GBs, I received exactly 1000 GBs (in decimal) or 952 GBs (in binary), both representing the same number.

### Summary

Bits and bytes are the basic building blocks of our computer system and are extremely important concept in C programming. Every variable, function, data type occupies different sizes of bytes in memory and C programming forces you to be aware of the bits and bytes that you are working with.