Math Fundamentals18 sections · 814 units
Open in Course

The XOR Operator

Exclusive OR

XOR (exclusive OR) returns true when inputs differ. If both are true or both are false, XOR returns false. Mathematically: ABA \oplus B.

Many languages lack a boolean XOR operator but have bitwise XOR (^). For booleans, you can write (a || b) && !(a && b) or a != b.

Example: canEdit XOR canDelete means you have exactly one permission, not both, not neither. XOR is less common than AND/OR but appears in parity checks and toggle logic.