| Author |
difference between !=(Not equal) and ^(XOR)
|
Jonah Hague
Greenhorn
Joined: Apr 28, 2008
Posts: 1
|
|
Is there another difference between an inequality test on booleans and an Exclusive OR besides the obvious fact that a XOR is only for booleans and a NOT EQUAL is also for ints, floats,... example: both of these if-statements seem to accomplish the same thing
|
 |
Nickolas Case
Ranch Hand
Joined: Apr 26, 2008
Posts: 98
|
|
XOR allows you to test against more than one argument and evaluates to true if and only if one of the arguments you are checking against is true. For example: Whereas != is only one argument at a time Hope this helps. [ April 28, 2008: Message edited by: Nickolas Case ]
|
 |
Dan Walin
Ranch Hand
Joined: Nov 11, 2003
Posts: 109
|
|
just for accuracy, in your sample code shouldn't it be: Using the equals "==" rather than the assignment "=" operator?
|
 |
Nickolas Case
Ranch Hand
Joined: Apr 26, 2008
Posts: 98
|
|
|
Yes it should. Adjusted accordingly. :-)
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
Nickolas if(true == false^true) is exactly the same as if(false^true) which is equivalent to if(false!=true) which again is exactly the same as if(true == (false!=true)) So I really don't understand the distinction you are making.
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
 |
|
|
subject: difference between !=(Not equal) and ^(XOR)
|
|
|