Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer
This is the forum to discuss the Wrox book Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer by Rod Stephens; ISBN: 9780470596906
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 25th, 2012, 10:29 PM
Authorized User
Points: 130, Level: 2
Points: 130, Level: 2 Points: 130, Level: 2 Points: 130, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2012
Location: Australia
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
Default Xor Logical Operator Question

Hi,

On page 139 of the book it talks about Logical Operators.

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.

Logically speaking, if both operands are true or both operands are false, does that return a false Xor??

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.
__________________
"These pretzels are making me thirsty"

Last edited by MinusZero; October 25th, 2012 at 10:35 PM.. Reason: Added another question
  #2 (permalink)  
Old October 25th, 2012, 11:53 PM
Rod Stephens's Avatar
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!)
  #3 (permalink)  
Old October 28th, 2012, 07:16 PM
Authorized User
Points: 130, Level: 2
Points: 130, Level: 2 Points: 130, Level: 2 Points: 130, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2012
Location: Australia
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks, that helps me alot! :)
__________________
"These pretzels are making me thirsty"


Similar Threads
Thread Thread Starter Forum Replies Last Post
Invalid operator for data type. Operator equals di Pusstiu SQL Server 2000 2 August 10th, 2007 04:51 AM
Logical c# problem iinf C# 0 November 30th, 2006 10:33 AM
Question about Logical database design in ERwin method SQL Server 2000 3 November 24th, 2005 12:38 PM
XOR Two Arrays coderforrent.com C++ Programming 1 September 14th, 2004 12:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.