ITPEC FE Morning April 2018 Question 1

There is a register where an integer value is stored in binary. Let x be a positive integer which is stored into the register, then perform the operations below.

(1)Shift the content of the register to the left by 2 bits(2)Add x to the register.

How many times larger than the integer x is the content of the register?

Explanation

5 times — a left shift by 2 bits multiplies by 22 = 4, and adding x once more makes 5x.

  • •Start: the register holds x
  • •Shift left 2 bits: x × 22 = 4x
  • •Add x: 4x + x = 5x

For example, x = 3 is 011; shifted left 2 bits it is 01100 = 12, and 12 + 3 = 15 = 5 × 3.

Answer (c)

Why not others:

  • •(a) 3 — 2x + x: treats the shift as 1 bit, which only doubles the value
  • •(b) 4 — stops after the shift and leaves out step (2), the addition of x
  • •(d) 6 — 4x + 2x: step (2) adds x once, not twice

Key rule: Shifting left by n bits multiplies by 2n, so shifts plus one addition or subtraction give multiplication by constants such as 5 = 4 + 1 or 7 = 8 − 1.

Basic Theory · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.