Binary and hex
Binary to decimal, decimal to hex, hex to binary — convert between the bases a computer is written in, at a width that keeps growing.
How it plays
A number written in one base — 0b for binary, 0x for hex, plain for decimal — and you give it in another. It starts at four bits, 8 to 15, and the width grows two bits at a time without end; new directions unlock as you climb.
The wrong options are the real slips: remainders read in the wrong order, the bits cut into fours from the wrong end, hex digits weighted by ten, a letter taken as its neighbour, one bit misread.
The working shows the route: place values added for binary, repeated division by 16 for hex, and four bits to every hex digit between the two. Answer by choosing, or type it.
Keys
Space starts and skips ahead · 1–9 pick · Enter submits · Esc stops. On a phone, tap.
What it trains
This makes reading and writing binary and hex quicker and surer. It trains that skill, not general reasoning.
Learn
How to get better at binary and hex: the method, the techniques, what each new level asks of you, and the traps the wrong answers are made of.
Your approach to each question
- Read the prefix first: 0b is binary, 0x is hex, no prefix is decimal. Then read the question’s target base. The route depends on the pair, not on the number.
- Between binary and hex, never go through decimal. Each hex digit is exactly four bits, so the conversion is a lookup, four bits at a time.
- Fix the size before the digits. A number of n bits sits between 2ⁿ⁻¹ and 2ⁿ − 1, so 0b1000100101 (ten bits) is between 512 and 1,023 — any option outside that range is out.
- With options shown, check the last digit next: an odd number ends in 1 in binary and in an odd digit in hex. Size and parity together usually leave one option.
Techniques and tricks
Know the sixteen nibbles cold
Learn 0000 to 1111 as the hex digits 0 to F, the way you know a times table. The letters are the ones that slow you: A is 10, B 11, C 12, D 13, E 14, F 15.
e.g. 1010 = 8 + 2 = A; 1100 = 8 + 4 = C; 0111 = 7; 1111 = F
Cut into fours from the right
To go from binary to hex, mark off groups of four starting at the right-hand end. The leftmost group may be short; pad it with zeros on the left.
e.g. 0b1101011 → 110 1011 → 0110 1011 → 0x6B
Double and add, left to right
For binary to decimal, start at the leftmost bit. For each next bit, double what you have and add the bit. You never need to know which power of two a place is.
e.g. 0b101101: 1 → 2 → 5 → 11 → 22 → 45
Take the largest power that fits
For decimal to binary, subtract the biggest power of two you can, then the next, and write 1 in each place you used and 0 in the rest. Know the powers of two up to 2¹⁶ = 65,536.
e.g. 100 = 64 + 32 + 4 → 1100100
Divide by 16, read remainders upward
For decimal to hex, divide by 16 and keep the remainder as a hex digit, then divide the quotient again. The last remainder you found is the first digit.
e.g. 1,000 ÷ 16 = 62 r 8; 62 ÷ 16 = 3 r 14 (E); 3 → 0x3E8
Weigh hex by 16, 256, 4,096
For hex to decimal, multiply each digit by its place — 1, 16, 256, 4,096, 65,536 — and add. Or run double-and-add with 16 in place of 2: times 16, add the next digit.
e.g. 0x3E8 = 3 × 256 + 14 × 16 + 8 = 768 + 224 + 8 = 1,000
Go wide numbers through hex
Past 16 bits, binary to decimal by place values is slow. Turn the bits into hex first, then weigh the hex digits; decimal to binary is the reverse, through hex and then four bits to each digit.
As the levels climb
- New directions arrive in a fixed order: binary → decimal, decimal → binary, binary → hex, hex → binary, hex → decimal, decimal → hex. Four in ten questions come from the newest one, so learn its route the moment it appears.
- The width starts at 4 bits (8 to 15) and grows two bits at a time without end. Past 8 bits, stop reading binary one bit at a time and read it as hex digits: four bits is one symbol to hold, not four.
- The clock starts at 5 seconds plus 1.1 for every bit, and closes in three steps to 55% of that. When it does, lean on the size and last-digit checks to pick from the options, and save full working for when two options survive.
- Past 16 bits the binary is printed in groups of four for you. Below that it is not, because grouping it is half the skill — count from the right every time.
Traps to avoid
- The remainders read top-down: dividing gives the last digit first. If you write the remainders in the order you found them, you get the number reversed — read them from the bottom up.
- Bits grouped from the left: 0b1101011 cut as 1101 011 gives D3, not 6B. Only the right-hand end has a full group of four for certain; start there.
- Hex weighted by ten: 0x3E8 read as 3 × 100 + 14 × 10 + 8 = 448, not 1,000. The places in hex are 1, 16, 256 — never 10 and 100.
- The neighbouring letter: B read as 10 or 12, E as 15. If an option differs from yours in one hex letter, say the letter’s value out loud — A is 10 — before you choose.
- One bit off, or a bit too many: an option one power of two from yours, or exactly double it. Count the bits of the prompt and check that your answer has the same width.
How to practise
- Untick all but one pair in “Directions” — binary → hex and hex → binary first — until the sixteen nibbles are instant. Every other direction gets faster once those are.
- Switch “Answer by” to “Typing it” once choosing feels easy. With options you can get by on size and parity; typing makes you produce every digit.
- Raise “Options shown” towards 8 to make the size check less decisive, so you have to convert the whole number rather than eliminate.
- Read the working on every miss. It shows the route for that pair at that width, and the route is what you are learning.
Levels
Each question has a clock that comes from the work it asks for. There is no last level: at least one dial turns without end. Your level is judged on your last ten answers, every ten: 90% moves you up, below 80% moves you down, which holds most people near four in five right.
All of it is in the settings beside Start — how many answers a judgement looks at and how often it recalibrates, the thresholds, the time, which questions, how many options, and whether you see each verdict at once or review them together at the judgement. You can also jump to any level.
More computing
All games →Bitwise
AND, OR, XOR, NOT, shifts, x AND (x − 1) and two's complement, worked bit by bit at a width that keeps growing.Powers of two
2ⁿ and back, GiB to MiB, and how many bits a number of values needs — the powers of two a programmer should have at hand.Big O by inspection
A few lines of loops or recursion: say how the work grows — O(n), O(n log n), O(n²), O(2ⁿ) — by reading the shape, not running it.Latency numbers
How many memory reads fit in a disk seek? Feel the gaps between cache, memory, disk and network, to the nearest power of ten.Data structures by hand
Push, pop, insert, probe: trace a stack, a queue, a search tree, a heap and a hash table by hand, and say what comes out or what the array holds.What does this query return?
A tiny table, a short SQL query: say what comes back. COUNT(*) or COUNT(x), NULL in a WHERE, LEFT JOIN counts, and NOT IN with a NULL.