# Bits, Bytes and Binary Codes

All images and every digital sounds are made from ‘0’s and ‘1’s. Each one of these digits is called a binary digit. Each binary digit is 1 bit. 8 bits make up a byte. Confused? Well don’t worry, that’s what bits, bytes and binary codes are in the short form. However, this post will go into more detail what they are and examples of how they are used and interpreted.

To understand bits, bytes and binary codes, you must know where they come from. In digital images, each colour on the image is called a pixel. A pixel is made up of these binary digits (01001101 etc…) that make up the one colour of that pixel. Here some important points you need to know about what these ‘bits, bytes and binary digits’ are:
• Each pixel is represented by a binary number. A binary digit can be either 0 or 1.
• 1 Binary digit = 1 bit.
• 8 bits = 1 byte.
• 1 kilobyte = 1024 bytes = 210 bytes (I will get onto why 1 kilobyte is not 1000 bytes later).
• 1 megabyte = 1,048,576 =  220 bytes.
The number of bits used to represent each pixel depends on how many colours you want.

No. of combinations = 2n  where n = number of bits

To make this clearer, I will use an example:

This is four bit binary as you can tell from the way only four binary digits are used only. Each column get’s doubled so the first column is 1, then 2, 4, 8, 16, 32 and so on…

From this, you can make 0-15 from four binary digits which is 16 different combinations.

Therefore, 16 = 2n  where n = number of bits which is 24

Let’s do a question using this theory.

Calculate the number of colours available if 1 pixel in an image = 3 bytes.

What we will do first is change that ‘byte’ into ‘bit’ as 8 bits make one byte.
8 x 3 = 24. This tells us there are 24 bits in each pixel of the image. It also tells us the number of bits in the image. Therefore, we can work out the number of colours:  224 = 16, 777, 216 (number of colours available in the image).

If you are revising Physics Topics, please have a look at other articles I have done on Physics you may be interested in.