Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1055
  • Last Modified:

What are the Eqv, Imp, and Xor Operators used for?

What are the Eqv, Imp, and Xor Operators used for?

Please give me some good easy-to-understand examples of why you'd use each of these logical operators. I've used the AND OR & NOT before, but I don't understand why you'd use any of the others.

Thanks!

-----

I have documentation on how they work and everything. I'm looking for reasons to use them. Examples in which it would make sense to actually put these to use. Thanks!
0
apm825
Asked:
apm825
1 Solution
 
rpaiCommented:
Eqv, Imp, Xor are bitwise operators and are not frequently used.

Eqv is the logical equivalence operator. As a Boolean operator, it returns True if both expressions are either True or False, but it returns False if one is True while the other is False. As a bitwise operator, it returns 1 if both bits are the same (that is, if both are 1 or both are 0), but it returns 0 if they are different.

Imp is the logical implication operator. As a Boolean operator, it returns True unless its first expression is True while the second is False. As a bitwise operator, it returns 1 unless the bit in the first expression is 1 while the bit in the second expression is 0. In VB .NET, Imp can be replaced with a combination of the Not and Or operators for logical operations.
For example,
bResult = (Not bFlag1) Or bFlag2
is equivalent to the statement:
bResult = bFlag1 Imp bFlag2

Xor operator returns a true if one, and only one, of the expressions evaluates to True. For example,
Expr1             Expr2            Result
0                  0                 0
0                  1                 1
1                  0                 1
1                  1                 0



0
 
DanRollinsCommented:
Hi apm825,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept rpai's comment(s) as an answer.

apm825, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
0
 
NetminderCommented:
Per recommendation, force-accepted.

Netminder
EE Admin
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now