---
title: "toU32(): IR builder function in typeshade/core/ir, TypeShade"
description: "toU32, an IR builder function in typeshade/core/ir. Convert to u32: the explicit numeric cast, where u32(/api/u32/) builds a literal from a JS number."
url: https://typeshade.dev/api/tou32/
language: en
---

# `toU32()`

Function in Builtins

Convert to `u32`: the explicit numeric cast, where `u32`(/api/`u32`/) builds a literal from a JS number.

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

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

## Syntax

```ts
const toU32: (x: ReadonlyNode<string> | number) => Node<"u32">
```

## Parameters

**`x` `ReadonlyNode<string> | number`**

## Return value

`Node<'u32'>`

## Description

Emits `u32(x)` on WGSL and `uint(x)` on GLSL. Use it over [`toI32`](https://typeshade.dev/api/toi32/) wherever the context is unsigned, such as a buffer stride.

## Examples

### Example

```ts
import { fn, toU32, f32T } from 'typeshade/core/ir'

const idx = fn('idx', { anchorMode: f32T }, ({ anchorMode }) => toU32(anchorMode))
```

## Targets

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

## See also

- [`u32`](https://typeshade.dev/api/u32/)
- [`toI32`](https://typeshade.dev/api/toi32/)

## Source

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