Binary numbers – bits, bytes, and representing information
Computer ScienceData & BinaryAges 11–12
Use it with your class: students open it from a link or a QR code, with no account needed.
A clickable sequence of 0/1 bits: each bit corresponds to a power of 2, and the decimal number is the sum of the bits that are set. Number mode converts between binary and decimal with a table of successive division by 2; Character mode shows the ASCII code and bit pattern as you type a character; Image mode lets you click cells to draw a black-and-white image, where each row is a sequence of bits. Students see that all information in a computer is ultimately a sequence of bits. Four more modes cover binary addition with carries and an overflow flag, logical shifts (× 2, ÷ 2, lost bits), two's complement negative numbers with subtraction by adding the complement, and hexadecimal in groups of 4 bits.
Lesson: Information in computers (bits, bit sequences, representing numbers, characters, and images)
What it shows
Computers represent all information with bits. In a binary number each bit has a place value that is a power of 2, so n bits can represent 2ⁿ values, from 0 to 2ⁿ − 1; the same bits can also encode a character (ASCII) or a black-and-white image. Binary addition works column by column with carries, and a carry out of the top bit means overflow. Shifting left multiplies by 2 and shifting right divides by 2, unless a 1 is lost. In two's complement the top bit has weight −2ⁿ⁻¹, so subtraction becomes adding the complement. Each hexadecimal digit stands for 4 bits.
How to use
Pick a Mode, click bits to switch them on and off, and watch the values, tables and flags update; change Number of bits to see the range grow. In Binary addition, set A and Second value B, then press Next column to add step by step. In Logical shifts, press Shift left ≪ 1 or Shift right ≫ 1 and read the lost bit. In Two's complement, try Change sign (−A) and watch A − B and the overflow flag V.
Parameters you can change
- Number of bits 4–16 bit
- Mode Decimal ↔ binary, Character encoding (ASCII), Black-and-white image with bits, Binary addition (carry, overflow), Logical shifts (× 2, ÷ 2), Two's complement (negatives, subtraction), Hexadecimal (groups of 4 bits)
- Initial value 0–65535
- Second value B (add, subtract) 0–65535
- Show the power of 2 on each bit
Questions to explore
- What is the largest number you can represent with 8 bits, and with 9 bits?
- Do the characters 'A' and 'a' have the same ASCII code? How do their bit patterns differ?
- How many bits and how many bytes does an 8 × 8 black-and-white image need?