Full Marks

A-level Computer Science Year 13 · Topic 12

Data representation and Boolean algebra

Data representation and Boolean algebra at A2 level goes deeper into how numbers and logic are handled.

We will work with signed integers, floating point representation, normalisation and arithmetic, and bitwise operations.

Then we cover character sets and data types, logic gates and De Morgan's laws, Karnaugh maps, adders and flip-flops.

In this topic

  1. 12.1Number bases and signed integers: binary, hexadecimal, sign and magnitude, two's complementFree below · 72 questions
  2. 12.2Floating-point representation and normalisationOpen in Full Marks · 62 questions
  3. 12.3Floating-point arithmetic, rounding errors and precisionOpen in Full Marks · 66 questions
  4. 12.4Bitwise manipulation, shifts and masksOpen in Full Marks · 60 questions
  5. 12.5Character sets (ASCII, Unicode) and primitive data typesOpen in Full Marks · 70 questions
  6. 12.6Logic gates, Boolean expressions and De Morgan's lawsOpen in Full Marks · 56 questions
  7. 12.7Boolean simplification and Karnaugh mapsOpen in Full Marks · 54 questions
  8. 12.8Half and full adders and D-type flip-flopsOpen in Full Marks · 57 questions

12.1 · Free notes

Number bases and signed integers: binary, hexadecimal, sign and magnitude, two's complement

Diagram: Number bases and signed integers: binary, hexadecimal, sign and magnitude, two's complement

Key points

In more detail

Practice

Number bases and signed integers: binary, hexadecimal, sign and magnitude, two's complement: 10 questions

Pick an answer to check it, or open the answer for the explanation.

1. Convert the binary number 10110110 to hexadecimal.

  1. D6
  2. A6
  3. 6B
  4. B6
Show answer

D: B6. Split into nibbles 1011 and 0110. 1011 = 11 = B and 0110 = 6, so the answer is B6.

2. What is the hexadecimal number 3F in denary?

  1. 15
  2. 51
  3. 48
  4. 63
Show answer

D: 63. 3 × 16 = 48, and F = 15, so 48 + 15 = 63.

3. What is -35 in 8-bit two's complement?

  1. 11011100
  2. 10100011
  3. 11011101
  4. 00100011
Show answer

C: 11011101. 35 = 00100011. Inverting gives 11011100, and adding 1 gives 11011101. 10100011 is the sign and magnitude form.

4. What range of integers can be stored in 8-bit two's complement?

  1. -127 to +127
  2. -128 to +127
  3. -128 to +128
  4. -127 to +128
Show answer

B: -128 to +127. The MSB has weight -128 and the other bits add at most 127. The range is therefore -128 to +127, with one zero.

5. A system stores integers in 8-bit sign and magnitude. What is the smallest value it can store?

  1. -126
  2. -127
  3. -255
  4. -128
Show answer

B: -127. One bit is the sign, leaving 7 magnitude bits that give a maximum magnitude of 127. The smallest value is -127.

6. Which statement about sign and magnitude and two's complement is correct?

  1. Sign and magnitude can store one more negative value
  2. Both have exactly one zero
  3. Sign and magnitude has two representations of zero
  4. Two's complement has two representations of zero
Show answer

C: Sign and magnitude has two representations of zero. Sign and magnitude has +0 (00000000) and -0 (10000000). Two's complement has a single zero and one extra negative value.

7. Using 8-bit two's complement, 53 - 20 is calculated as 53 + (-20). What is the 8-bit result?

  1. 00100001
  2. 01000001
  3. 11011111
  4. 00110101
Show answer

A: 00100001. -20 = 11101100. 00110101 + 11101100 = 1 00100001. Discard the carry to leave 00100001 = 33.

8. In 8-bit two's complement, 01100100 + 01000000 (100 + 64) is calculated. What happens?

  1. Overflow: 10100100 is read as -92
  2. The correct result 164 is stored as 10100100
  3. Underflow: the result is -164
  4. The carry is lost harmlessly so the answer is 36
Show answer

A: Overflow: 10100100 is read as -92. 164 is above +127, so the result 10100100 has the sign bit set and reads as -92. Two positives giving a negative signals overflow.

9. Why is hexadecimal often used instead of binary to display memory addresses?

  1. Hex arithmetic is faster for the processor
  2. Computers store data in hexadecimal internally
  3. Each hex digit is exactly 4 bits, so it is shorter and less error-prone
  4. Hex can show negative numbers without a sign bit
Show answer

C: Each hex digit is exactly 4 bits, so it is shorter and less error-prone. One hex digit represents a nibble, so values are far more compact and easier for humans to read. Hardware still uses binary.

10. The 8-bit two's complement value 11110110 (-10) is sign-extended to 16 bits. What is the result?

  1. 1111111100000110
  2. 1000000001110110
  3. 0000000011110110
  4. 1111111111110110
Show answer

D: 1111111111110110. Sign extension copies the sign bit (1) into the new high bits, giving 1111111111110110, which is still -10.

Keep going in Full Marks

Full Marks has 72 questions on Number bases and signed integers: binary, hexadecimal, sign and magnitude, two's complement (62 more than here), set out in practice levels. You also get notes and 3D models for all 8 subtopics of Data representation and Boolean algebra, plus games, timed exams and past papers.

On your exam board

All A-level Computer Science Year 13 topics