- How do I check if a permission level has ANY of multiple permissions, not ALL?
- Use BITAND with a condition that checks if the result is greater than 0. For example, to see if a user has Read (1) OR Write (2): =IF(BITAND(level, 3)>0, "Has at least one", "Has neither"). The mask 3 combines bits 1 and 2; any non-zero result means at least one permission exists.
- Why does BITAND(4, 2) return 0?
- Because 4 in binary is 100 and 2 in binary is 010—they share no common bits. BITAND only returns 1 where both numbers have a 1 in the same position. This is the correct and expected behavior; it means those two values have no overlapping flags.
- What's the practical limit on the size of numbers BITAND can handle?
- BITAND works with integers up to 2^48 - 1 (about 281 trillion) in Excel and Google Sheets. Beyond that, precision degrades. For systems requiring larger bit flags, consider restructuring as separate boolean columns instead.
- What's the difference between BITAND and the AND function?
- AND evaluates logical conditions and returns TRUE or FALSE, used in decision logic like =AND(hours>8, status="approved"). BITAND performs binary arithmetic on the bit representations of integers, used for flag checking like =BITAND(permissions, 4). Use AND for booleans; use BITAND for bit manipulation.