# bitXor() Function & Examples

Use the bitXor() bitwise function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## bitXor

#### bitXor(x, y)

Try it yourself:

```calculio
bitOr(1, 2)
bitXor([2, 3, 4], 4)
```

---

## bitXor(): mark differing bits

**bitXor(a, b)** performs exclusive OR. A result bit is 1 when the inputs differ at that position. Thus `bitXor(12, 10)` compares `1100` with `1010` and returns `0110`, or 6.

## A useful toggle

XOR is reversible: applying the same mask twice restores the original value. That makes `bitXor(value, mask)` useful for toggling selected flags and for simple change detection. It is not encryption; a fixed XOR mask is easily reversed.

## Explore the bits

Use [bin()](https://calcul.io/function/bin/index.md) to make the differing positions visible. For a union of enabled flags use [bitOr()](https://calcul.io/function/bitOr/index.md); for shared flags use [bitAnd()](https://calcul.io/function/bitAnd/index.md); use [bitNot()](https://calcul.io/function/bitNot/index.md) to complement a mask.

## Use integer values

Bitwise operators are defined for integers. Round fractional measurements deliberately before using them, and take care with negative operands and externally specified word sizes.

[All functions](https://calcul.io/functions/index.md)
