bit manipulation - Java: Why is it called bitwise exclusive or? -


I am trying to understand how bitwise exclusive or works in Java Example For:

  false ^ false = false true ^ true = false true ^ false = true false ^ true = true  

According to some terms here In java, the size of boolean is jvm dependent. Usually boolean can be displayed on the stack with 32 bits , in the 8 bits array.

So, why is it called bitwise if it is more than a byte on the stack?

According to the java language specificity, there is no boolean bitwise operator, only more .

15.22.1 Integer bitwise operator & amp;, ^, and |

When both operators of operator and, ^, or | There is a type of convertible (§5.1.8) of a primitive integral type, the binary numerical promotion is done on the first operand (§5.6.2).

Bitware operator type of expression;

For more, the result value is bitwise and operable values.

For ^, the value of the result is a bitwash exclusive or operand value.

| For this, the result value is included in bitwise or

15.22.2 Boolean logical operators & amp ;, ^, and |

When both of the other amp, operands, ^, or | Operator type of boolean or boolean, then the type of bitware operator expression is boolean. In all cases, the operators are essentially subject to the conversion (§5.1.8), it is necessary.

For, the result value is true if both operand values ​​are true; Otherwise, the result is false.

For ^ ^, the result value is true if operand values ​​are different; Otherwise, the result is false.

For this, the value of the result is false if both operand values ​​are false; Otherwise, the result is correct.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -