Skip to content
SPM Tuition
Computer Science · Boolean logic and representation

Representation size versus the value represented

You mix up how many bits a number needs with what the number is.

Every stored value has two separate facts: its size, which is how many bits it uses, and its value, which is the number or character the bits stand for. Keep them apart and most representation questions become simple.

This lesson closes Boolean logic and representation. Conversions between denary and binary are covered in converting data representations within scope.

What are the two questions?

For any question about bits, first decide which one is being asked.

Question Asks about Example
How many bits? Size How many bits does 100 need?
What value? Meaning What number is 01100100?

Each has its own method. For size, you count the bits or find the smallest n with 2ⁿ large enough. For value, you add the place values of the 1s.

Worked example: one value, two sizes

The value 5 is 4 + 1, so its binary form is 101. In 3 bits it is 101. In 8 bits it is 00000101.

Size Pattern Value
3 bits 101 5
8 bits 00000101 5

The value is unchanged. Only the size differs, because leading zeros add no value. A computer stores values in fixed-size cells, so it adds the zeros to fill the cell.

The size also sets the range. With 3 bits there are 2³ = 8 patterns, so the largest unsigned value is 7. A value of 8 does not fit in 3 bits, and neither does 9.

How many bits does a value need?

Find the smallest n where 2ⁿ is greater than the value. For 100, list the powers of 2: 64, 128. Since 64 is less than 100 and 128 is greater, n is 7 because 128 = 2⁷.

Check: the largest 7-bit value is 2⁷ − 1 = 127, which is at least 100. The largest 6-bit value is 63, which is less than 100. So 7 bits is the smallest size.

The mistake: bit count as the value

A common slip is to treat the number of bits as if it were the number. A student sees “8 bits” and writes the value 8, or sees 1000 and calls it one thousand.

Question Wrong thinking Right thinking
Value of 00001000 8 bits, so 8 The 1 is in the 2³ place, so the value is 8, and the size is 8 bits
Value of 1000 One thousand 2³ = 8
Values in 4 bits 4 2⁴ = 16 patterns, for 0 to 15

In the first row both answers happen to be 8, which hides the mix-up. Try 00000100: the size is still 8 bits but the value is 4. Changing the value does not change the size.

Characters are values too

A character such as 7 is stored as a code, not as the number it shows. In ASCII the character 7 has the code 55, which is 00110111 in 8 bits. The number 7 is 00000111.

So 00110111 could mean the value 55 or the character 7, depending on what the program treats it as. The pattern alone does not tell you, so always check what the question says the bits stand for.

Check yourself

(a) How many different values can 6 bits represent? (b) What is the smallest number of bits needed for the value 200? (c) What is the value of 00010110 and how many bits does the pattern use?

Answer

(a) 2⁶ = 64 different patterns, which stand for 0 to 63 if unsigned.

(b) 2⁷ = 128 is less than 200 and 2⁸ = 256 is greater, so 8 bits. The largest 8-bit value is 255, which is enough. The largest 7-bit value is 127, which is not.

(c) The 1s are in the places worth 16, 4 and 2, so the value is 16 + 4 + 2 = 22. The pattern uses 8 bits. The value and the size are separate answers.

What to study next

Practise all four skills together in the integrated practice set. Log any size and value mix-ups in the mistake log and paper-error review.

If you want a teacher to go through your conversions and range questions, see online one-to-one Computer Science tuition.

Common questions

How many different values can n bits represent?

Two to the power of n different patterns. Three bits give 8 patterns, eight bits give 256 and ten bits give 1 024. For unsigned whole numbers those patterns stand for 0 up to 2ⁿ − 1.

How many bits does a number need?

The fewest bits such that 2ⁿ is greater than the number. For 100, 2⁶ = 64 is too small and 2⁷ = 128 is enough, so 7 bits. Check the answer by confirming the largest n-bit value is at least the number.

Do leading zeros change the value?

No. 00000101 and 101 are both the value 5. The first uses 8 bits and the second uses 3, so the size differs but the value does not. Computers store values in a fixed size, such as 8 bits.

Is the character 7 the same as the number 7 in memory?

No. A character is stored as a code, and the character 7 has its own code (55 in ASCII). The number 7 is stored as a value, 00000111 in 8 bits. They are different patterns with different meanings.

If bit and value questions keep giving different answers, one-to-one Computer Science lessons let a teacher ask you which of the two the question wants and check each answer against a table.

  • Online one-to-one lessons for your child with an experienced teacher.
  • Your first class is a one-hour trial, from RM50. The fee is agreed before you book.
  • Happy with the teacher? Continue with lessons of about 1.5 hours. If not, ask for another teacher.