Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a logical (boolean) XOR function in C or C++ standard library? [duplicate]

Tags:

c++

xor

I didn't find one, but have a hard time believing there is none.

like image 717
Violet Giraffe Avatar asked Jun 10 '13 12:06

Violet Giraffe


People also ask

Does C have XOR?

The ^ (bitwise XOR) in C or C++ takes two numbers as operands and does XOR on every bit of two numbers. The result of XOR is 1 if the two bits are different. The << (left shift) in C or C++ takes two numbers, left shifts the bits of the first operand, the second operand decides the number of places to shift.

What is XOR boolean operation?

Exclusive or or exclusive disjunction is a logical operation that is true if and only if its arguments differ (one is true, the other is false). Exclusive or. XOR.

Which operator is used for logical XOR operation?

The XOR logical operation, exclusive or, takes two boolean operands and returns true if, and only if, the operands are different. Conversely, it returns false if the two operands have the same value.

Is XOR a boolean operator?

XOR is one of the sixteen possible binary operations on Boolean operands. That means that it takes 2 inputs (it's binary) and produces one output (it's an operation), and the inputs and outputs may only take the values of TRUE or FALSE (it's Boolean) – see Figure 1.


1 Answers

Boolean XOR is the same thing as !=, "not equal."

p | q | p != q
--+---+-------
F | F |   F    
T | F |   T    
F | T |   T    
T | T |   F    

http://en.wikipedia.org/wiki/Truth_table#Logical_conjunction

like image 104
Matt Ball Avatar answered Sep 21 '22 13:09

Matt Ball