---
title: "BinOp: type in IR, TypeShade API reference for developers"
description: "BinOp, a type in IR. The operator tag on Expr.binop: arithmetic (+ - * /), remainder (%) and bitwise."
url: https://typeshade.dev/api/binop/
language: en
---

# `BinOp`

Type in IR

The operator tag on Expr.binop: arithmetic (+ - \* /), remainder (%) and bitwise.

`import type { BinOp } from 'typeshade'`
`import type { BinOp } from 'typeshade/core/ir'`

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```ts
type BinOp = '+' | '-' | '*' | '/' | '%' | '&' | '|' | '^' | '<<' | '>>';
```

## Description

Each is spelled the same way in WGSL and GLSL and evaluated the same way by the CPU backend. On floats `%` is a truncating remainder, so its sign follows the dividend: WGSL’s native `%` behaves this way, and the GLSL backend writes `a - b * trunc(a / b)` because GLSL ES 3.00’s own `%` is integer-only. When a negative operand is possible and a floor modulo is wanted, use [`mod`](https://typeshade.dev/api/mod/), which is floor-mod on every target; the `.mod()` method on `Node` emits this truncating `%`. For integer operands the CPU backend follows WGSL: two’s-complement wrap, truncating `/` with `x / 0 = x` and `x % 0 = 0`, and `<<`/`>>` as logical shifts on `u32`, with `>>` on `i32` an arithmetic (sign-preserving) shift.

## See also

- [`mod`](https://typeshade.dev/api/mod/)

## Source

[`src/core/ir/nodes/operators.ts`, line 14](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/nodes/operators.ts#L14), at commit af54ddad5
