---
title: "trunc(): IR builder function in typeshade/core/ir, TypeShade"
description: "trunc, an IR builder function in typeshade/core/ir. trunc(x): round toward zero, component-wise."
url: https://typeshade.dev/api/trunc/
language: en
---

# `trunc()`

Function in Builtins

`trunc(x)`: round toward zero, component-wise.

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

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

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

## Syntax

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

## Parameters

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

## Return value

`Node<K>`

## Targets

| Target | Support | Notes |
| --- | --- | --- |
| WGSL (WebGPU) | Supported | `trunc(x)`. |
| GLSL ES 3.00 (WebGL2) | Supported | `trunc(x)`. |
| CPU oracle | Supported | Evaluated in `f64` by the oracle. |

## In the guide

- [The CPU oracle](https://typeshade.dev/guide/internals/the-cpu-oracle/)

## See also

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

## Source

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