Signed up recently but had issues with the confirmation email?

Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.

Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.

Revision notesQuestionsFor schools
Revise Computing
Log inStart revising free
Revision notesQuestionsFor schoolsLog in

© 2026 Revise Computing · revisecomputing.co.uk

Worried about something?Question Bank UpdatesPrivacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).

Knowledge/A Level/H446/01 Computer systems/Data Types/Bitwise manipulation and masks

Bitwise manipulation and masks: shifts, combining with AND, OR and XOR

Bitwise manipulation and masks: shifts, combining with AND, OR, and XOR

1.4.1 Data Types

Practise exam questions

Data Types — Note 9 of 10

Candidates should be able to perform right and left logical shifts. Candidates should understand the effect of right and left shifts on a binary numbers. Candidates should understand the purpose of using masks with bitwise operators, and should have experience of applying masks using AND, OR and XOR.

What you need to know

Bitwise operations work on the individual bits of a binary value. Shifts move bits left or right, and masks combined with AND, OR or XOR can check, clear, set or toggle particular bits.

What to know

  • A left shift of n places multiplies an unsigned value by 2^n (as long as no 1s are shifted out); a right shift of n places divides by 2^n (rounding down).
  • AND with a mask: CLEARS bits where the mask is 0 and KEEPS bits where the mask is 1. Used to check or extract bits.
  • OR with a mask: SETS bits to 1 where the mask is 1, and leaves the others unchanged.
  • XOR with a mask: TOGGLES (flips) bits where the mask is 1, and leaves the others unchanged.
  • Uses: extracting part of a value (e.g. the lower nibble), setting or clearing status flags, checking whether a number is odd (AND with 00000001).

Code examples

Masks with AND, OR and XOR
text
Value       1 0 1 1 0 1 1 0
AND mask    0 0 0 0 1 1 1 1   -> 0 0 0 0 0 1 1 0  (keep lower nibble)
OR  mask    0 1 0 0 0 0 0 1   -> 1 1 1 1 0 1 1 1  (set bits 6 and 0)
XOR mask    1 1 1 1 1 1 1 1   -> 0 1 0 0 1 0 0 1  (flip every bit)

Shift left 1:   0 1 1 0 1 1 0 0  (MSB lost)
Shift right 2:  0 0 1 0 1 1 0 1

Key terms

Logical shift

All bits move left or right by a number of places; bits shifted out are lost and the empty positions are filled with 0s.

Mask

A binary pattern combined with a value using a bitwise operator to select or change particular bits.

Exam technique

  • Tip:Write the value and mask directly above each other and work through column by column.
  • Tip:When describing a shift, give the direction, the number of places AND the factor, e.g. 'shift right 2 places to divide by 4'.
  • Tip:If asked for the PURPOSE of a mask, say what it is used for (to extract, set or clear particular bits), not just what happens to each bit.
  • Mistake:Forgetting that bits shifted off the end are lost, which can change the result unexpectedly.
  • Mistake:Adding the mask to the value, or mixing up the shift directions. A mask is applied column by column with AND, OR or XOR, with no carries; a left shift multiplies and a right shift divides.

Past exam questions

  • June 2025Paper 1Q3(b)2marks
  • June 2025Paper 1Q3(d)(i)2marks
  • June 2025Paper 1Q3(d)(ii)1mark
  • November 2020Paper 1Q3(c)(i)2marks
  • November 2020Paper 1Q3(c)(ii)2marks
  • June 2018Paper 1Q9(f)1mark
  • June 2018Paper 1Q9(g)1mark
  • June 2017Paper 1Q6(c)2marks

Ready to test yourself?

Practise 1.4.1 questions
← Previous noteFloating point arithmetic: addition and subtraction1.4.1 Data TypesNext note →How character sets (ASCII and UNICODE) are used to represent text1.4.1 Data Types

Back to Data Types

Data Types

Note 9 of 10

  1. 1Primitive data types: integer, real/floating point, character, string and Boolean
  2. 2Represent positive integers in binary
  3. 3Sign and magnitude and two's complement to represent negative numbers
  4. 4Addition and subtraction of binary integers
  5. 5Represent positive integers in hexadecimal
  6. 6Convert positive integers between binary, hexadecimal and denary
  7. 7Representation and normalisation of floating point numbers in binary
  8. 8Floating point arithmetic: addition and subtraction
  9. 9Bitwise manipulation and masks: shifts, combining with AND, OR and XOR
  10. 10How character sets (ASCII and UNICODE) are used to represent text
Topic overview