---
title: "u32(): IR builder function in typeshade/core/ir, TypeShade"
description: "u32, an IR builder function in typeshade/core/ir. A u32 literal node. Literals, typed references and the constructors that turn a JavaScript value into a node."
url: https://typeshade.dev/api/u32/
language: en
---

# `u32()`

Function in Values

A `u32` literal node.

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

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

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

## Syntax

```ts
function u32(v: number): Node<'u32'>;
function u32(x: ReadonlyNode<ScalarCastSource>): Node<'u32'>;
```

## Parameters

**`v` `number`**

## Return value

`Node<'u32'>`

## Exceptions

**`TypeError`**

`v` is neither a JS number nor a scalar node.

**[`SD0116`](https://typeshade.dev/reference/errors/sd0116/)**

[`SD0116`](https://typeshade.dev/reference/errors/sd0116/) when the node operand is not a scalar.

## Description

Use it over the `f32` default wherever WGSL demands an unsigned scalar: buffer strides, vertex and instance indices, bit-flag masks used with `.bitAnd` and `.bitOr`.

A Node argument is a cast instead: `u32(x)` converts, the free-function twin of `x.u32()`. It builds what [`toU32`](https://typeshade.dev/api/tou32/) builds, and its operand is bounded to a scalar.

## Examples

### Example

```ts
import { u32 } from 'typeshade/core/ir'

const flags = u32(4)  // Node<'u32'>
```

## Targets

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

## In the guide

- [Language guide](https://typeshade.dev/guide/internals/)
- [Your first shader](https://typeshade.dev/guide/internals/your-first-shader/)
- [Values and mutation](https://typeshade.dev/guide/internals/values-and-mutation/)
- [Functions and entry points](https://typeshade.dev/guide/internals/functions-and-entry-points/)
- [Control flow](https://typeshade.dev/guide/internals/control-flow/)
- [Layouts and resources](https://typeshade.dev/guide/internals/layouts-and-resources/)
- [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

- [`u32()`](https://typeshade.dev/reference/functions/u32/)
- [`toU32`](https://typeshade.dev/api/tou32/)

## Source

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