Discrete math · Boolean algebra and logic circuits
Common tricks with bit masks in code are Boolean algebra applied to every bit at once.