NOTE: 1 + 1 is mapped to 1 there.
This works in Perl somehow. (1+1 =2 is still true)
But don't ! It's not recommended ... rather a workaround in languages without boolean operators.²
Just sketch the truth table to see how it works.
Better use && and || instead.
> Y = (A & B)
that's definitely wrong, because & is for a bitwise and not a logical.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
to elaborate more: the standard false value in Perl is not 0 but empty string '' . While the latter will be evaluated to 0 in arithmetic operations it might cause a confusion.
DB<7> print !!0 DB<8> print !!1 1
²) and only for simple cases, b/c you risk a number overflow when multiplying true values.
> perl -E "say ((1+1) * (1+1) * (1+1));" 8
In reply to Re: Boolean operation: (A & B) vs (A * B)
by LanX
in thread Boolean operation: (A & B) vs (A * B)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |