Data representation in bits – numbers, text, images, sound
Computer ScienceData & BinaryAges 15–16
Use it with your class: students open it from a link or a QR code, with no account needed.
Four familiar data types are all reduced to a bit sequence. Type an integer to see its binary form and the number of bytes needed; type a line of text to see the code of each character; drag the color depth and resolution sliders to see the image get worse but the file get lighter; drag the sample rate and bit depth to see the sound wave break into steps. Each mode shows the formula for the storage size in use.
Lesson: Digital data: the binary system, character encoding, image and audio data, and units of storage
What it shows
Computers store every kind of data as bits, and this simulation shows how four data types are converted. An integer is written in base 2, and k bits give 2ᵏ different values. Text is stored as a numeric code for each character, taken from an encoding table such as ASCII or Unicode. A digital image is a grid of pixels, so its uncompressed size is number of pixels × color depth. Sound is sampled at regular intervals, and its size is sample rate × bit depth × channels × duration ÷ 8 bytes. In every case, higher quality costs more bits.
How to use
Pick a Data type or use the Integer, Characters, Image and Sound buttons. In Image mode, lower the color depth and resolution and compare the picture with the original 24-bit image while the file size falls. In Sound mode, reduce the sample rate and bit depth and watch the blue digital signal lose the shape of the gray wave. Ask students to check each size with the formula shown below the display.
Parameters you can change
- Data type Integer, Characters and text, Digital image, Sound
- Color depth / audio bit depth 1–24 bit
- Image resolution (side) 8–256 pixels
- Audio sample rate 2–48 kHz
- Audio duration 1–300 seconds
Questions to explore
- How many bytes does an uncompressed 128 × 128 image with 24-bit color need?
- Why does a higher sample rate make the digital signal follow the real sound wave more closely?
- How many different colors can one pixel show with a color depth of 1, 8 and 24 bits?