# bitOr() Function & Examples

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

## bitOr

#### x | y

#### bitOr(x, y)

Try it yourself:

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

---

## bitOr(): set bits from either value

**bitOr(a, b)** performs a bitwise OR: each result bit is 1 when either input has a 1 in that position. `bitOr(12, 10)` combines `1100` and `1010` into `1110`, or 14.

## Combining flags

OR is the usual operation for building a flag set. If read permission is 1 and write permission is 2, `bitOr(1, 2)` creates the value 3 containing both. It does not remove bits already present, so it is ideal for enabling options.

## Related bit operations

Inspect masks with [bin()](https://calcul.io/function/bin/index.md). Test whether a flag is present with [bitAnd()](https://calcul.io/function/bitAnd/index.md), toggle it with [bitXor()](https://calcul.io/function/bitXor/index.md), and invert a mask with [bitNot()](https://calcul.io/function/bitNot/index.md). For hexadecimal notation, see [hex()](https://calcul.io/function/hex/index.md).

## Input caveat

Use integer operands. Negative values are valid under signed integer semantics but are harder to read because their high sign bits are set; document the intended width when values cross a system boundary.

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