---
title: "round(): IR builder function in typeshade/core/ir, TypeShade"
description: "round, an IR builder function in typeshade/core/ir. round(x): nearest integer, ties to even, component-wise, on both targets."
url: https://typeshade.dev/api/round/
language: en
---

# `round()`

Function in Builtins

`round(x)`: nearest integer, ties to even, component-wise, on both targets.

`import { round } from 'typeshade/core/ir'`

This export returns an IR node. A `"use typeshade"` file calls the builtin itself: [`round()`](https://typeshade.dev/reference/functions/round/)

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

## Syntax

```ts
const round: <K extends FloatKey>(x: ReadonlyNode<K>) => Node<K>
```

## Parameters

**`x` `ReadonlyNode<K>`**

## Return value

`Node<K>`

## Description

`round(x)`: nearest integer, ties to even, component-wise, on both targets. This differs from JS `Math.round`, which rounds halves toward +∞. WGSL’s `round` is ties-to-even; GLSL ES 3.00’s `round` leaves exact halves to the implementation, so the GLSL output uses `roundEven`.

## Targets

| Target | Support | Notes |
| --- | --- | --- |
| WGSL (WebGPU) | Supported | `round(x)`. Over `f64` operands the fp64 pass rewrites it into its `df64` helper. |
| GLSL ES 3.00 (WebGL2) | Supported | `roundEven(x)`. Over `f64` operands the fp64 pass rewrites it into its `df64` helper. |
| CPU oracle | Supported | Evaluated in `f64` by the oracle. |

## In the guide

- [The CPU oracle](https://typeshade.dev/guide/internals/the-cpu-oracle/)
- [fp64](https://typeshade.dev/guide/internals/fp64/)
- [Migrating a GLSL shader](https://typeshade.dev/guide/internals/migrating-a-glsl-shader/)

## See also

- [`round()`](https://typeshade.dev/reference/functions/round/)

## Source

[`src/core/ir/node.ts`, line 1308](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L1308), at commit af54ddad5
