`Xor`

Operator

For Boolean expressions, returns “true” if they have different values. For integer expressions, does a bitwise XOR operation.

## Syntax

```
expression_1 Xor expression_2
```

## Parts

`expression_1`

- A Boolean or integer expression.
`expression_2`

- A Boolean or integer expression.

## Instructions

For Boolean expressions, the result is true only if `expression_1`

and `expression_2`

hold different values at the same time.
The table that follows shows how to find this result.

If `expression_1` is |
And `expression_2` is |
Then the result is |
---|---|---|

True | True | False |

True | False | True |

False | True | True |

False | False | False |

For bitwise operations, the operator `Xor`

compares each bit at the same position in the two numeric expressions.
The table that follows shows how to calculate the bit in the result.

If the bit in `expression_1` is |
And the bit in `expression_2` is |
Then the bit in the result is |
---|---|---|

1 | 1 | 0 |

1 | 0 | 1 |

0 | 1 | 1 |

0 | 0 | 0 |

Note: The logical and bitwise operators have lower precedence than the arithmetic and relational operators. Thus, we recommend that you put parentheses around bitwise operations to make sure they give correct results.

## Examples

```
Var a = 255, b = 170, c = 85
Var a_xor_b = a Xor b
Var a_xor_c = a Xor c
Var b_xor_c = b Xor c
```

Variable | Value |
---|---|

`a` |
255 (11111111) |

`b` |
170 (10101010) |

`c` |
85 (01010101) |

`a_xor_b` |
85 (01010101) |

`a_xor_c` |
170 (10101010) |

`b_xor_c` |
255 (11111111) |