# bin() Function & Examples

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

## bin

#### bin(value)

Try it yourself:

```calculio
bin(2)
```

[oct](https://calcul.io/function/oct/index.md)

[hex](https://calcul.io/function/hex/index.md)

---

## bin(): display a number in binary

**bin(x)** converts an integer value into its binary representation. Binary uses only 0 and 1, making it the natural notation for flags, masks, permissions, and low-level data.

## Reading binary output

`bin(10)` produces `0b1010`: 8 + 2 equals 10. Each position represents a power of two. The `0b` prefix identifies the notation, so the result is not mistaken for a decimal string. For negative values, the displayed representation follows the calculator’s integer rules; confirm the width and signedness required by an external protocol.

## Use it for bitwise work

Binary is especially helpful beside [bitAnd()](https://calcul.io/function/bitAnd/index.md), [bitOr()](https://calcul.io/function/bitOr/index.md), and [bitXor()](https://calcul.io/function/bitXor/index.md). Convert a mask with bin(), inspect the set positions, then use the appropriate operation. [bitNot()](https://calcul.io/function/bitNot/index.md) is also useful, but its result depends on integer representation.

## Input caveats

Supply integers. A fractional value has no simple finite binary integer representation and should be rounded intentionally with [floor()](https://calcul.io/function/floor/index.md) or [round()](https://calcul.io/function/round/index.md) only when that is mathematically appropriate. For hexadecimal output, use [hex()](https://calcul.io/function/hex/index.md).

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