Skip to content

!= on Booleans is XOR

On two Boolean values, != is exclusive or: TRUE exactly when they differ. The parser rejects A != B and offers XOR, which is the same function under its logical name.

The diagnostic recorded below: != is not an expression operator; use XOR when the two sides must differ. The two-input XOR table is the “not equal” table: FALSE on the rows where A and B agree, TRUE on the two rows where they differ. In Python, True != False is True; in Java a != b on two boolean values is exclusive or; in JavaScript a !== b on Booleans is the same.

The reason to translate rather than accept the spelling is the chain. a != b != c in Python is a chained comparison, a != b and b != c, while A XOR B XOR C is parity; the two are different functions, and a parser that accepted != as XOR would read Python wrongly. Writing XOR makes the parity reading explicit, and the pitfall page on three-input XOR shows the row on which parity and “exactly one” differ.

The same family of signs, =, == and !=, covers equality, the biconditional and exclusive or, and each has its own pitfall page. The symbols page records all of them with the parser's message.

What the parser says

You typedCodeWhy it is rejectedRepair offered
A != Bunsupported-operator`!=` is not an expression operator. Use `XOR` when the two sides must differ.Replace with XOR

The common slip

Writing A != B for “A and B are different conditions” in a rule, meaning that both apply but are distinct. The formula says the two values differ at run time, which is exclusive or; the sentence was not about values at all.

Questions

Is A XOR B the same as NOT (A <-> B)?

Yes. Exclusive or is the negation of the biconditional, and XNOR, the biconditional, is the negation of XOR. The equivalence checker proves it on four rows.

What is != on integers?

Ordinary inequality, which has nothing to do with XOR; 3 != 5 is TRUE and 3 ^ 5 is 6. The translation to XOR applies only to two Boolean operands.

Related

Tools

See also

Pitfalls

Generated from the Tangibool engine, semantics tangibool-semantics/1, engine 1.0.0, build . Every table, map, simplification and verdict on these pages was computed by the Tangibool engine when the site was built, and every claim was re-checked by the same exact checker the app uses. Limits are stated where they apply. © 2026 Foreranger LTD.