Skip to content

Fundamentals: Data Representation

All information in a computer is represented using binary. Different data types have different encoding methods.

Text

ASCII Table

Choose a range and click build table to view a larger extract of the ascii table

Tip: ASCII printable range is 32–126 (space to tilde).
Dec Hex Char HTML Entity Description

Characters are stored using codes such as ASCII (7-bit) or Unicode (UTF-8, UTF-16). Each letter or symbol has a numeric code which is stored in binary.

Key Definitions

Term Definition
Character set A collection of characters that a computer can recognise and store, each with a unique binary code.
ASCII A character set using 7 bits to represent 128 different characters (letters, digits, punctuation, control codes).
Extended ASCII An 8-bit character set allowing 256 characters, often used for symbols and accented letters.
Unicode A character set designed to represent characters from most of the world’s writing systems, using more bits.
Encoding The process of converting characters into binary numbers so they can be stored and processed by a computer.

How it works

  1. Each character on your keyboard, including letters, numbers, and symbols, is assigned a unique numerical value.
  2. The numberical value assigned to each character is standardised by the Character set. To examples of character sets are ASCII (American Standard Code for Information Interchange) and Unicode. ASCII only supports American characters with only 128 possible values using 7 binary digits. Unicode is usually represented in 16 or 32 bits and supports the many different characters avail in all languages and other symbols including emojis
  3. For example, the letter 'H' is 72, 'e' is 101, 'l' is 108, and 'o' is 111.
  4. These decimal numbers are then converted into binary code (a series of 1s and 0s), which is the language computers understand.
  5. When you type "Hello," the device converts it to its binary equivalent, sends it, and the receiving device converts it back into ASCII, displaying the original text.

Images

Interactive 4x4 Image Creator

Choose a colour depth, then a colour, and click on the grid to paint pixels. Binary values update below.

Row Binary Values

Images are stored as a grid of pixels. Each pixel has a binary value representing its colour, often using RGB values. The number of bits used per pixel is called the colour depth.

Key Definitions

Term Definition
Pixel The smallest unit of a digital image, represented by a square of colour.
Resolution The number of pixels in width × height. Higher resolution gives more detail.
Colour depth The number of bits used to represent the colour of each pixel. More bits = more colours.
Metadata Extra information stored with the image, such as file type, resolution, colour depth, or date taken.
File size Calculated using image width × image height × colour depth, determining the storage required.

How it works

  1. An image is made up of tiny squares called pixels. Each pixel stores a single colour.
  2. Each colour is represented using binary. The number of binary digits used per pixel is called the colour depth, this impacts how many colours are available. For greyscale images, each pixel is given a value (e.g. from 0 = black to 255 = white). For colour images, pixels are often stored using the RGB model: Red, Green, and Blue values each range from 0 to 255. Example: (255, 0, 0) = pure red.
    So, a single pixel in RGB needs 3 numbers (Red, Green, Blue), which means: 8 bits for Red + 8 bits for Green + 8 bits for Blue = 24 bits per pixel.
  3. The computer stores the binary for each pixel, row by row, like a grid. Extra information (called metadata) is stored too, this includes:
    • Image width and height
    • Colour depth (bits per pixel)
    • File format (e.g. JPEG, PNG, BMP)

Sound

Interactive Sound Sampling Demo

Change the sample rate and bit depth to see how digital sound approximates an analogue wave.

20 samples/cycle 256 possible levels

Sound is represented by sampling the amplitude of sound waves at regular intervals. The quality depends on the sample rate and bit depth.

Key Definitions

Term Definition
Sample Rate The number of samples of audio carried per second, measured in Hertz (Hz).
Bit Depth The number of bits used to represent each sample, which determines the number of possible amplitude levels.
Amplitude The height of the sound wave, representing loudness or volume of the sound.
Frequency The number of cycles of a sound wave per second, measured in Hertz (Hz), perceived as pitch.
File Size Calculated using sample rate × bit depth × number of channels × duration, determining the storage required.

How it works

  1. Sound in the real world is analog – it’s a continuous wave of vibrations in the air. Computers can’t store continuous waves directly, so they must convert them into binary.
  2. The sound wave is measured (or sampled) at regular intervals. Each measurement records the amplitude (height) of the wave at that point in time. The number of samples taken per second is called the sample rate (measured in Hz).
    Example: CD quality sound = 44,100 samples per second (44.1 kHz).
  3. The accuracy depends on the bit depth (number of bits used per sample). Example:
    • 8-bit → 256 possible values
    • 16-bit → 65,536 possible values
    A higher bit depth means the sound is stored more accurately.
  4. Each sample value is then converted into binary. All the binary values are stored in sequence, along with extra metadata like:
    • Sample rate
    • Bit depth
    • Number of channels (mono or stereo)

Numbers

Integers are stored as binary whole numbers. Real numbers can be represented using fixed-point or floating-point binary formats, allowing fractions and very large/small values. See more Binary