View Single Post
  #2 (permalink)  
Old October 25th, 2012, 11:53 PM
Rod Stephens's Avatar
Rod Stephens Rod Stephens is offline
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Quote:
In the definition of Xor (^) it states that "It returns true if one of its operands is true and the other is false".

It doesnt explain how Xor returns false though.
Sorry, it returns false otherwise. In other words, it returns false if both are true or both are false.

The truth table is:
T ^ T = F
T ^ F = T
F ^ T = T
F ^ F = F
Quote:
Also, with OR and XOR, are you limited to only two operands for comparison? I would assume with AND you could have more than two.
All of these operators take only 2 arguments (and "not" takes 1) but you can chain them together just like you can with + or -. For example:
A ^ B ^ C ^ D
is equivalent to:
((A ^ B) ^ C) ^ D
You can do similar things for || and &&.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)