Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the logical functions IMP and EQV do in VB6? Has anyone found a real world use for them?

And, Or, Xor and Not I understand. What I don't get are Imp and Eqv. What do they mean? How'd they get in there? Is there any real use for them?

like image 551
bugmagnet Avatar asked May 29 '09 17:05

bugmagnet


People also ask

What are the logical operators in Visual Basic?

VB.NET supports four logical operators: And , AndAlso , Or , OrElse , Not , and Xor .

What are logical operators?

A logical operator is a symbol or word used to connect two or more expressions such that the value of the compound expression produced depends only on that of the original expressions and on the meaning of the operator. Common logical operators include AND, OR, and NOT.

What operator results in a Boolean value that is opposite of its operand in other words if the operand is true it results in false and if the operand is false it results in true?

The Not Operator performs logical negation on a Boolean expression. It yields the logical opposite of its operand. If the expression evaluates to True , then Not returns False ; if the expression evaluates to False , then Not returns True .


2 Answers

IMP is "material implication" "a implies b" or "if a then b", which is equivalent to NOT a OR b. EQV is "equivalence" or "if and only if", so a EQV b is the same as (a IMP b) AND (b IMP a).

They got there because someone wanted to be complete. They can shorten some logical expressions, but you can always express the same thing with NOT and AND, NOT and OR, or with XOR alone.

like image 130
Charlie Martin Avatar answered Oct 21 '22 13:10

Charlie Martin


Here is the truth table for all the operators, both for boolean and for bitwise. The best time to use them is when you map your logic and realize you have a function that takes two inputs, and has the same outputs as those operators:)

------------------------------------------------------------------------------------------------------------------
|AND  |     |     |     |OR   |     |     |     |XOR  |     |     |     |IMP  |     |     |     |EQV  |     |     |
------------------------------------------------------------------------------------------------------------------
|In1  |In2  |Out1 |     |In1  |In2  |Out1 |     |In1  |In2  |Out1 |     |In1  |In2  |Out1 |     |In1  |In2  |Out1 |
------------------------------------------------------------------------------------------------------------------
|False|False|False|     |False|False|False|     |False|False|False|     |False|False|True |     |False|False|True |
------------------------------------------------------------------------------------------------------------------
|False|True |False|     |False|True |True |     |False|True |True |     |False|True |True |     |False|True |False|
------------------------------------------------------------------------------------------------------------------
|False|Null |False|     |False|Null |Null |     |False|Null |Null |     |False|Null |True |     |False|Null |Null |
------------------------------------------------------------------------------------------------------------------
|True |False|False|     |True |False|True |     |True |False|True |     |True |False|False|     |True |False|False|
------------------------------------------------------------------------------------------------------------------
|True |True |True |     |True |True |True |     |True |True |False|     |True |True |True |     |True |True |True |
------------------------------------------------------------------------------------------------------------------
|True |Null |Null |     |True |Null |True |     |True |Null |Null |     |True |Null |Null |     |True |Null |Null |
------------------------------------------------------------------------------------------------------------------
|Null |False|False|     |Null |False|Null |     |Null |False|Null |     |Null |False|Null |     |Null |False|Null |
------------------------------------------------------------------------------------------------------------------
|Null |True |Null |     |Null |True |True |     |Null |True |Null |     |Null |True |True |     |Null |True |Null |
------------------------------------------------------------------------------------------------------------------
|Null |Null |Null |     |Null |Null |Null |     |Null |Null |Null |     |Null |Null |Null |     |Null |Null |Null |
------------------------------------------------------------------------------------------------------------------
|     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |     |
------------------------------------------------------------------------------------------------------------------
|In1  |In2  |Out1 |     |In1  |In2  |Out1 |     |In1  |In2  |Out1 |     |In1  |In2  |Out1 |     |In1  |In2  |Out1 |
------------------------------------------------------------------------------------------------------------------
|001  |001  |001  |     |001  |001  |001  |     |001  |001  |000  |     |001  |001  |111  |     |001  |001  |111  |
------------------------------------------------------------------------------------------------------------------
|001  |010  |000  |     |001  |010  |011  |     |001  |010  |011  |     |001  |010  |110  |     |001  |010  |100  |
------------------------------------------------------------------------------------------------------------------
|001  |011  |001  |     |001  |011  |011  |     |001  |011  |010  |     |001  |011  |111  |     |001  |011  |101  |
------------------------------------------------------------------------------------------------------------------
|001  |100  |000  |     |001  |100  |101  |     |001  |100  |101  |     |001  |100  |110  |     |001  |100  |010  |
------------------------------------------------------------------------------------------------------------------
|010  |001  |000  |     |010  |001  |011  |     |010  |001  |011  |     |010  |001  |101  |     |010  |001  |100  |
------------------------------------------------------------------------------------------------------------------
|010  |010  |010  |     |010  |010  |010  |     |010  |010  |000  |     |010  |010  |111  |     |010  |010  |111  |
------------------------------------------------------------------------------------------------------------------
|010  |011  |010  |     |010  |011  |011  |     |010  |011  |001  |     |010  |011  |111  |     |010  |011  |110  |
------------------------------------------------------------------------------------------------------------------
|010  |100  |000  |     |010  |100  |110  |     |010  |100  |110  |     |010  |100  |101  |     |010  |100  |001  |
------------------------------------------------------------------------------------------------------------------
|011  |001  |001  |     |011  |001  |011  |     |011  |001  |010  |     |011  |001  |101  |     |011  |001  |101  |
------------------------------------------------------------------------------------------------------------------
|011  |010  |010  |     |011  |010  |011  |     |011  |010  |001  |     |011  |010  |110  |     |011  |010  |110  |
------------------------------------------------------------------------------------------------------------------
|011  |011  |011  |     |011  |011  |011  |     |011  |011  |000  |     |011  |011  |111  |     |011  |011  |111  |
------------------------------------------------------------------------------------------------------------------
|011  |100  |000  |     |011  |100  |111  |     |011  |100  |111  |     |011  |100  |100  |     |011  |100  |000  |
------------------------------------------------------------------------------------------------------------------
like image 29
Pillgram Avatar answered Oct 21 '22 15:10

Pillgram