Bitwise Operations Simulator
Apply AND, OR, XOR, NOT, logical and arithmetic shifts and rotations to 8-bit values, and use masks to set, clear and test bits.
Operation
Result bit is 1 only if both bits are 1. Use it with a mask to clear bits or test one bit.
Bits
Click bits of A or B to change them. Bits that change in the result are marked orange.
Common masks
AND truth table
| A | B | A AND B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
About This Simulation
This bitwise operations simulator applies AND, OR, XOR, NOT, shifts and rotations to 8-bit values. Click bits to change the operands, try common masks for setting, clearing, toggling and testing bits, and see the result in binary, denary and hexadecimal.
Features
- AND, OR, XOR and NOT on values from 1 to 16 bits
- Logical shift left and right, arithmetic shift right
- Rotate left and right
- Clickable bits and preset bit masks
- Truth tables and ×2 / ÷2 explanations for shifts
Topics covered
- Bitwise Operators
- Bit Masking
- Logical Shifts
- Arithmetic Shifts
- Rotation
Explanation
Bitwise operations work on each bit of a binary number separately. They are used to manipulate individual bits, for example to read status flags, set options, pack data efficiently or multiply and divide quickly by powers of two.
How it works
- AND with a mask keeps only the bits where the mask is 1. Use it to clear bits or to test whether a bit is set.
- OR with a mask sets the bits where the mask is 1 and leaves the others unchanged.
- XOR with a mask flips (toggles) the bits where the mask is 1.
- A logical shift left by n multiplies an unsigned value by 2ⁿ; a logical shift right divides by 2ⁿ, with 0s coming in.
- An arithmetic shift right copies the sign bit in, so it divides signed two's complement numbers correctly.
- A rotate (circular shift) moves the bit that falls off one end back in at the other end.
Why it matters
Shifts and masks are on the Cambridge AS Level syllabus and in assembly language programming. Bitwise operations are used in device drivers, graphics, networking (subnet masks), encryption and compression.
Frequently Asked Questions
What is a bit mask?
A binary value used with AND, OR or XOR to select which bits of another value are cleared, set or toggled.
What is the difference between a logical and an arithmetic shift?
A logical right shift always brings in 0s. An arithmetic right shift copies the sign bit, so negative two's complement numbers stay negative.
How do you test if a bit is set?
AND the value with a mask that has only that bit set. A non-zero result means the bit is 1.
Why can shifting left lose information?
Bits shifted off the left end are discarded, so if any of them were 1 the result is no longer the original value × 2.
Related Simulations
Number Systems
Two's Complement Simulator
Convert between denary and two's complement binary, with the invert-and-add-one steps and the negative place value shown.
Logic Gates
Logic Gate Circuit Builder
Build simple logic circuits, truth tables, K-maps, and simplify boolean expressions
Number Systems
Number System Converter
Convert between binary, decimal, hex, octal
Number Systems
Floating Point Representation Simulator
Store numbers as a two's complement mantissa and exponent, normalise them and see rounding errors, plus IEEE 754 32-bit and 64-bit.

