Bitwise Or and Exclusive Or

Bitwise Or and Exclusive Or

Binary "|" returns its operands ORed together bit by bit.

Binary "^" returns its operands XORed together bit by bit.

Although no warning is currently raised, the results are not well defined when these operations are performed on operands that aren't either numbers (see Integer Arithmetic) nor bitstrings (see Bitwise String Operators).

Note that "|" and "^" have lower priority than relational operators, so for example the parentheses are essential in a test like

print "false\n" if (8 | 2) != 10;

If the experimental "bitwise" feature is enabled via use feature 'bitwise' , then this operator always treats its operand as numbers. This feature produces a warning unless you also use no warnings 'experimental::bitwise' .

doc_perl
2016-12-06 03:18:24
Comments
Leave a Comment

Please login to continue.