FoundationHigher

Binary and Data Representation

GCSE Computing — Data Representation

The binary number system

Computers process and store all data using binary, a base-2 number system that uses only two digits: 0 and 1. Each binary digit is called a bit. A group of 8 bits is called a byte, which is the standard unit of data storage. Binary works because computer hardware is built from transistors that have two states: on (1) and off (0). Every piece of data, from text and numbers to images and sound, must ultimately be represented in binary for a computer to process it.

In the denary (decimal) system we use daily, each column represents a power of 10. In binary, each column represents a power of 2. Reading from right to left, the columns represent 1, 2, 4, 8, 16, 32, 64, 128 for an 8-bit binary number.

Key Facts

  • 1 bit = a single binary digit (0 or 1).
  • 1 nibble = 4 bits. 1 byte = 8 bits.
  • 8-bit binary can represent values from 0 (00000000) to 255 (11111111).
  • Each hexadecimal digit represents exactly 4 binary bits.
  • ASCII uses 7 bits to represent 128 different characters.

Converting decimal to binary

To convert a decimal number to binary, start with the highest power of 2 that fits into the number and work downwards. For each column, if the value fits, write a 1 and subtract it; otherwise write a 0.

Worked Example

Convert 78 to an 8-bit binary number.

Column values: 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1
128 does not fit into 78, so write 0. Remaining: 78.
64 fits into 78, so write 1. Remaining: 78 - 64 = 14.
32 does not fit into 14, so write 0. Remaining: 14.
16 does not fit into 14, so write 0. Remaining: 14.
8 fits into 14, so write 1. Remaining: 14 - 8 = 6.
4 fits into 6, so write 1. Remaining: 6 - 4 = 2.
2 fits into 2, so write 1. Remaining: 2 - 2 = 0.
1 does not fit into 0, so write 0.
Answer: 01001110

Binary addition

Binary addition follows simple rules: 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, and 1 + 1 = 10 (which means write 0 and carry 1 to the next column). If a carry produces 1 + 1 + 1, the result is 11 (write 1 and carry 1). An overflow error occurs when the result of a calculation is too large to be stored in the available number of bits, for example when adding two 8-bit numbers produces a 9-bit result.

Hexadecimal

Hexadecimal (hex) is a base-16 number system that uses digits 0 to 9 and letters A to F (where A = 10, B = 11, C = 12, D = 13, E = 14, F = 15). Programmers use hex because it provides a more compact and human-readable way to represent binary values. Each hex digit corresponds to exactly 4 binary bits (one nibble), so a byte can be written as just two hex digits instead of eight binary digits. For example, the binary value 11111111 is FF in hex and 255 in decimal. Hex is commonly used for colour codes in web design (such as #FF5733), memory addresses and MAC addresses.

ASCII character encoding

ASCII (American Standard Code for Information Interchange) is a character encoding system that assigns a unique 7-bit binary number to each character. It covers 128 characters including upper and lower case letters, digits 0 to 9, punctuation marks and control characters. For instance, the letter A is represented by the decimal value 65 (binary 1000001) and the letter a by 97 (binary 1100001). Unicode is an extended system that uses up to 32 bits per character, allowing it to represent over a million characters from every writing system in the world.

Image representation

Digital images are made up of tiny dots called pixels. Each pixel stores a colour value as binary data. The resolution of an image is determined by the number of pixels it contains; more pixels produce a sharper image but require more storage. Colour depth refers to the number of bits used to store the colour of each pixel. A 1-bit colour depth gives two colours (black and white). An 8-bit colour depth gives 256 colours. A 24-bit colour depth (true colour) gives over 16 million colours. The file size of an image can be estimated using the formula: file size = width in pixels multiplied by height in pixels multiplied by colour depth in bits.

Worked Example

Calculate the file size of an image that is 800 pixels wide, 600 pixels tall, with a 24-bit colour depth. Give your answer in kilobytes.

Total pixels = 800 x 600 = 480,000 pixels.
Total bits = 480,000 x 24 = 11,520,000 bits.
Total bytes = 11,520,000 / 8 = 1,440,000 bytes.
Total kilobytes = 1,440,000 / 1,024 = approximately 1,406 KB.
Answer: approximately 1,406 KB (about 1.4 MB).

Practice Questions

  1. Convert the decimal number 203 to an 8-bit binary number. (2 marks)
  2. Add the binary numbers 01101011 and 00110101. Show your working. (3 marks)
  3. Explain why hexadecimal is used instead of binary by programmers. (2 marks)
  4. Explain the relationship between colour depth, resolution and file size of an image. (4 marks)

Study Essentials

As an Amazon Associate we may earn from qualifying purchases.