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.
Bitwise manipulation and masks: shifts, combining with AND, OR, and XOR
1.4.1 Data Types
Practise exam questionsData 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.
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.
2^n (as long as no 1s are shifted out); a right shift of n places divides by 2^n (rounding down).00000001).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 1All bits move left or right by a number of places; bits shifted out are lost and the empty positions are filled with 0s.
A binary pattern combined with a value using a bitwise operator to select or change particular bits.
Past exam questions
Ready to test yourself?
Practise 1.4.1 questions