Scenario
A user should have read and export access, but a support screenshot shows the export button disabled. Permissions are stored as a bitmask, and the UI gates the button with mask & EXPORT_FLAG. Someone claims the mask is right; someone else claims the flag constant is wrong. Doing binary AND in your head under pressure is how this bug shipped in the first place — evaluate it explicitly.
Broken input
stored mask: 0b0101
export flag: 0b1000
check: mask & flag
Goal
Use Bitwise Operations Calculator to prove whether the stored bitmask includes the permission bit the UI is checking. A bitwise AND that evaluates to zero means the permission is genuinely absent — the UI is behaving correctly and the data is wrong.
Tool sequence
- Open Bitwise Operations Calculator.
- Enter
0101and1000as the two operands and select AND, keeping the bit width at the size the application uses (here 4 bits is enough). - Read the result row — the calculator shows the operation bit by bit, so you can see which positions overlap.
0101 & 1000produces0000: no overlap, so the export bit is simply not set in the stored mask.- Cross-check the flag constants in Binary / Hex / Decimal Converter — a wrong constant like
8where the schema says export is bit 2 (4) produces exactly this symptom.
Checkpoint output
0101 (stored mask: read + execute bits)
& 1000 (export flag, bit 3)
------
0000 → export permission NOT present
The AND result is zero, so the stored mask never contained the export bit. The fix is in whatever writes the mask, not in the UI check.
Common mistakes
- Comparing decimal-looking values like
5and8without converting them to binary at the same width first. - Using OR when you meant to test membership —
mask | flagis always truthy, so the check silently passes for everyone. - Ignoring the signed/unsigned interpretation when the high bit is involved at full register width.
- Fixing the constant in one place while the same magic number lives in a migration or a second service.
Related tools and lessons
- Binary / Hex / Decimal Converter - Convert exact integers between base 2, 10, and 16.
- Two's Complement Calculator - Convert signed decimals to fixed-width binary and back.
- Truth Table Generator - Generate propositional logic truth tables in the browser.
- Related lesson: Convert a Feature Flag Between Binary, Hex, and Decimal
- Related lesson: Decode a Negative Integer from Fixed-Width Binary