Question

Is there a name for logical AND with the negation (~) of the second variable, i.e:

A & (~B)

The truth table for such operation is:

0 & (~0) = 0
0 & (~1) = 0
1 & (~0) = 1
1 & (~1) = 0

And in longer sequences of bits,

A       = 10110011
B       = 10111001
A & B   = 10110001
A &(~B) = 00000010

PS - I'm interested with OR with the negation of the second variable, too.

Was it helpful?

Solution

Incredible. A & (~B) is called Material nonimplication, and A | (~B) is called Material implication Seems that every possible binary operation has a name.

OTHER TIPS

The set theoretic term is the "relative complement" of B with respect to A.

I like to call it bit clearer. You find it in code also in the form by using an assignment:

A = A & ~B

Or more compact as:

A &= ~B

Example: Before: A = 0x0007, B=0x0004 After: A = 0x0003

It has the effect that it clears the bits B from A. But relative complement, and hence the name difference, you could write it as follows A \ B, like the set difference, is also a good name.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top