Bits and binary

Computers use - the digits 0 and 1 - to store data. A binary digit, or , is the smallest unit of data in computing. It is represented by a 0 or a 1. Binary numbers are made up of binary digits (bits), eg the binary number 1001.

The circuits in a computer's processor are made up of billions of . A transistor is a tiny switch that is activated by the electronic signals it receives. The digits 1 and 0 used in binary reflect the on and off states of a transistor.

Computer programs are sets of instructions. Each instruction is translated into - simple binary codes that activate the . Programmers write computer code and this is converted by a into binary instructions that the processor can .

All , music, documents, and any other information that is processed by a computer, is also stored using binary.

Encoding

Everything on a computer is represented as streams of binary numbers. Audio, images and characters all look like binary numbers in machine code. These numbers are encoded in different data formats to give them meaning, eg the 8-bit pattern 01000001 could be the number 65, the character 'A', or a colour in an image.

Encoding formats have been standardised to help compatibility across different platforms. For example:

• audio is encoded as audio file formats, eg mp3, WAV, AAC
• video is encoded as video file formats, eg MPEG4, H264
• text is encoded in character sets, eg ASCII, Unicode
• images are encoded as file formats, eg BMP, JPEG, PNG

The more bits used in a pattern, the more combinations of values become available. This larger number of combinations can be used to represent many more things, eg a greater number of different symbols, or more colours in a picture.

Did you know?

In the early days of computing, the only way to enter data into a computer was by flicking switches or by feeding in punched cards or punched paper tape.

Since computers work using binary, with data represented as 1s and 0s, both switches and punched holes were easily able to reflect these two states - 'on' to represent 1 and 'off' to represent 0; a hole to represent 1 and no hole to represent 0.

Charles Babbage's Analytical Machine (in 1837) and the (used during the Second World War) were operated using punched cards and tapes. Modern computers still read data in binary form but it is much faster and more convenient to read this from microchips or from magnetic or optical disks.

Andrew Robinson explains how binary data is used when monitoring birds with a Raspberry Pi