Bitwise Operators
Bitwise operators act on integer bit patterns. Number bitwise operations typically convert operands to 32-bit integers; BigInt has separate integer bitwise behavior.
Flags can share one number, but ordinary reading counts should not be rounded with a bitwise shortcut.
See the mechanism
0110Follow one example
Binary 01 and 10 combine with OR into 11, decimal 3. AND with 01 checks the saved bit. AND with the inverted saved mask clears that bit, leaving 10, decimal 2. Number coercion can discard fractions and high-order information, so do not use | 0 as a general safe conversion.
Predict, change and check
Predict: If only FEATURED is set, what does flags & SAVED produce?
Test your explanation: Test 0, 1, 2 and 3. Write their two-bit forms beside the results before adding another flag.
The tasks below ask you to explain that result and apply the idea to different inputs.
Apply and distinguish
A bit mask is a chosen representation
Most Number bitwise operations convert values to 32-bit integer representations, which can discard information from larger or fractional inputs. The unsigned right shift produces an unsigned 32-bit Number result; BigInt has different supported operators and does not support unsigned right shift.
For permission-like flags, define which bit represents each flag and keep those meanings stable. x & mask tests selected bits; x | mask sets bits; x & ~mask clears bits. A nonzero mask result is not automatically true unless you convert it or compare it deliberately. Test absent, present and combined flags.
Check your understanding: State the input contract, identify the operation that changes the result, and give one boundary input that would distinguish the correct rule from the mistake described above.