Stephen Swensen
Stephen Swensen

Reputation: 22297

How to do boolean exclusive or?

Apparently there is no boolean version of the bitwise exclusive-or operator (^^^)... what to do?

Upvotes: 31

Views: 8114

Answers (2)

Daniel
Daniel

Reputation: 47904

let inline xor a b = (a || b) && not (a && b)

Upvotes: 4

Greg Hewgill
Greg Hewgill

Reputation: 993243

This is provided by the not-equal operator <>.

Upvotes: 58

Related Questions