---
title: "xor function in Strata | Oplema"
description: "Compare two integers bit by bit, setting each result bit where exactly one input bit is set. For example, xor(17, 5) returns 20."
url: "https://oplema.com/docs/strata/functions/xor"
updated: "2026-11-04"
---

# xor

Bitwise XOR.

## Try an expression

In [Formula](https://oplema.com/docs/strata/prep/formula), enter the expression and set Output type to **INTEGER**.

### Expression

```
xor(17, 5)
```

### Result

```
20
```

To use your own data, replace the example values with column names. Keep format strings and other options as written.

Try it live in Formula

Result
| id | result |
| --- | --- |
| 1 | 20 |

## Arguments and types

```
xor(left, right)
```

**left**

Number, Bits

**right**

Number, Bits

Supported signatures (11)

```
xor(left: BIGINT, right: BIGINT) → BIGINT
xor(left: BIT, right: BIT) → BIT
xor(left: HUGEINT, right: HUGEINT) → HUGEINT
xor(left: INTEGER, right: INTEGER) → INTEGER
xor(left: SMALLINT, right: SMALLINT) → SMALLINT
xor(left: TINYINT, right: TINYINT) → TINYINT
xor(left: UBIGINT, right: UBIGINT) → UBIGINT
xor(left: UHUGEINT, right: UHUGEINT) → UHUGEINT
xor(left: UINTEGER, right: UINTEGER) → UINTEGER
xor(left: USMALLINT, right: USMALLINT) → USMALLINT
xor(left: UTINYINT, right: UTINYINT) → UTINYINT
```

The result type can depend on the input types. See DuckDB for the full argument rules.

## Things to know

If the first argument is missing, the result is NULL.

## Related functions

[abs

Return the absolute value of a number, removing any minus sign.

](https://oplema.com/docs/strata/functions/abs)[acos

Computes the arccosine of x.

](https://oplema.com/docs/strata/functions/acos)[acosh

Computes the inverse hyperbolic cos of x.

](https://oplema.com/docs/strata/functions/acosh)[add

Add two values.

](https://oplema.com/docs/strata/functions/add)

[Browse numbers](https://oplema.com/docs/strata/functions#numbers) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/numeric.html#xorx-y)

Function metadata from DuckDB, used under the [MIT license](https://github.com/duckdb/duckdb/blob/v1.5.4/LICENSE).
