Data Representation
All the data representation topics in one place — bases, two's complement, shifts, file sizes, and ASCII. Perfect for GCSE Computer Science revision.
Type in any field — the others update instantly.
Enter a whole number between 0 and 255
Denary to binary is a subtraction method. Write out the place values — 128, 64, 32, 16, 8, 4, 2, 1 for an eight-bit number — then work left to right. If a place value fits into what remains, write a 1 and subtract it; if not, write a 0.
Binary to hex is faster than most students expect, provided you never route it through
denary. Split the binary into groups of four bits from the right and convert each group to
a single hex digit. 11011010 becomes 1101 1010, which is
DA. Going via denary is slower and is where errors creep in.
Two's complement is how negative numbers are stored. To negate a value, invert every bit and add one. The leftmost bit then acts as a sign bit — 0 for positive, 1 for negative.
The reason it is used rather than a simple sign bit is worth knowing, because questions ask for it: two's complement lets the processor add and subtract using the same circuitry, with no special handling for negative values.
Write out the place values from left to right — 128, 64, 32, 16, 8, 4, 2, 1 for eight bits. Work from the largest downwards: if the place value fits into the number that remains, write a 1 and subtract it; if not, write a 0. Continue until nothing remains. For example 181 gives 10110101.
Split the binary number into groups of four bits, starting from the right, then convert each group into a single hex digit. 11011010 splits into 1101 and 1010, which are D and A, giving DA. Never convert via denary — it is slower and introduces errors.
Two's complement is how computers represent negative binary numbers. To negate a number, invert every bit and then add one. The leftmost bit acts as a sign bit: 0 means positive, 1 means negative. It is used because it allows addition and subtraction to be performed by the same circuitry, with no separate rules for negatives.
Hexadecimal is a compact, human-readable shorthand for binary. One hex digit maps to exactly four bits, so long binary strings become short and far easier to read, write and check without error. It is not that computers use hex internally — they work in binary. Hex exists for the benefit of people.
A left shift moves every bit left, filling with zeros on the right, which multiplies the number by two for each place shifted. A right shift moves bits right and divides by two per place, discarding any bits that fall off the end. Those discarded bits are lost, so information can be destroyed by shifting.
Overflow occurs when the result of a calculation needs more bits than are available to store it. Adding two eight-bit numbers whose total exceeds 255 produces a ninth bit with nowhere to go, so the stored result is wrong. Exam answers should say the result cannot be represented in the number of bits available.