bitAnd(): combine matching bits
bitAnd(a, b) performs a bitwise AND. A result bit is 1 only when the corresponding bit is 1 in both inputs. For example, bitAnd(12, 10) compares 1100 and 1010, producing 1000, or 8.
Masks and permissions
AND is the standard way to test a bit mask. If a flag is present in a value, bitAnd(value, flag) returns a non-zero result. This is compact and fast for sets of Boolean options such as feature switches or file permissions.
Inspect the calculation
Use bin() to see both operands in binary. To set flags, use bitOr(); to toggle differences, use bitXor(). bitNot() can clear selected positions when combined carefully.
Input rules
Bitwise operations are intended for integers. Decide explicitly how to handle decimal inputs, and be cautious with negative numbers because signed binary representations and width conventions affect their interpretation. For logical truth values rather than integer bits, use and.