The same number, three ways. Binary (base 2) is how a computer holds it, denary (base 10) is how we count, and hexadecimal (base 16) is a short way to write binary: each hex digit stands for four bits. Change the number in any panel, by sliding the bits or typing a value, and the other two follow, each with its working.
- Binary to denary: each bit has a place value, doubling from 1 on the right (1, 2, 4, 8, 16 …). Add up the place values of the bits that are 1.
- Denary to binary: divide by 2 again and again, writing down each remainder. The remainders, read from the last one back up to the first, are the bits.
- Binary to hexadecimal: split the bits into groups of four (nibbles) from the right. Each nibble is worth 8 + 4 + 2 + 1, from 0 to 15, written as one hex digit: 0 to 9, then A to F for 10 to 15.
- Hexadecimal to denary: each hex digit has a place value too, multiplying by 16 (1, 16, 256, 4096). Multiply each digit by its place value and add them up.
Signed numbers (two's complement). Choose Signed and the leftmost bit becomes the sign bit, with a negative place value (−128 in 8 bits). Add up the place values as before, counting the sign bit as negative. To write a negative number in binary, write its size in binary, flip every bit, then add 1. The hex is always the bit pattern, so a negative number and its pattern share the same hex.
Questions. Choose Questions for ten at a time in the size and kind of number chosen (8 or 16 bits, unsigned or signed): each gives a number in one base and asks for it in another. Every wrong option is a common mistake, and picking one says which; the right one shows the working. Start again gives ten new ones.
Objective: convert positive integers between binary, denary and hexadecimal, and represent negative integers in two's complement (Cambridge International AS & A Level Computer Science 9618 1.1; IGCSE 0478 1.1).
Where this fits
- AP: AP Computer Science Principles Goes beyond AP Computer Science Principles: Hexadecimal and two's complement aren't in AP CSP; binary to and from decimal is.
- AQA: AQA A Level Computer Science (7517)
- Cambridge: Cambridge IGCSE Computer Science (0478); Cambridge A Level Computer Science (9618); Cambridge AS Level Computer Science (9618)
- IB: IB Computer Science HL; IB Computer Science SL
- Pearson Edexcel International: Edexcel International GCSE Computer Science (4CP0)
- USDP: USDP Computer Science