---
title: "u32(): typeshade/core/ir의 IR 빌더 함수, TypeShade 컴파일러 API"
description: "u32, typeshade/core/ir의 IR 빌더 함수입니다. u32 리터럴 노드입니다. 리터럴과 타입이 붙은 참조, 그리고 자바스크립트 값을 노드로 바꾸는 생성자입니다."
url: https://typeshade.dev/ko/api/u32/
language: ko
---

# `u32()`

함수, 값 분류

`u32` 리터럴 노드입니다.

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

이 export는 IR 노드를 반환합니다. `"use typeshade"` 파일에서는 내장 함수 자체를 부릅니다: [`u32()`](https://typeshade.dev/ko/reference/functions/u32/)

설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.

## 구문

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

## 매개변수

**`v` `number`**

## 반환값

`Node<'u32'>`

## 예외

**`TypeError`**

`v`가 JS 숫자도 스칼라 노드도 아닐 때 발생합니다.

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

노드 피연산자가 스칼라가 아니면 [`SD0116`](https://typeshade.dev/ko/reference/errors/sd0116/)이 발생합니다.

## 설명

WGSL이 부호 없는 스칼라를 요구하는 곳에서는 기본값인 `f32` 대신 이 함수를 사용합니다. 버퍼 스트라이드, 버텍스와 인스턴스 인덱스, `.bitAnd`와 `.bitOr`에 쓰는 비트 플래그 마스크가 그런 자리입니다.

Node를 인자로 넘기면 캐스트가 됩니다. `u32(x)`는 변환이며, `x.u32()`의 독립 함수 버전입니다. [`toU32`](https://typeshade.dev/ko/api/tou32/)와 같은 노드를 만들고, 피연산자는 스칼라로 제한됩니다.

## 예제

### 예제

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

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

## 대상별 지원

| 대상 | 지원 | 비고 |
| --- | --- | --- |
| WGSL (WebGPU) | 지원 | `u32(a)`로 생성합니다. |
| GLSL ES 3.00 (WebGL2) | 지원 | `uint(a)`로 생성합니다. |
| CPU 오라클 | 지원 | 오라클이 `f64`로 계산합니다. |

## 관련 가이드

- [작성 가이드](https://typeshade.dev/ko/guide/internals/)
- [첫 셰이더](https://typeshade.dev/ko/guide/internals/your-first-shader/)
- [값과 변경](https://typeshade.dev/ko/guide/internals/values-and-mutation/)
- [함수와 진입점](https://typeshade.dev/ko/guide/internals/functions-and-entry-points/)
- [제어 흐름](https://typeshade.dev/ko/guide/internals/control-flow/)
- [레이아웃과 리소스](https://typeshade.dev/ko/guide/internals/layouts-and-resources/)
- [CPU 오라클 안내서](https://typeshade.dev/ko/guide/internals/the-cpu-oracle/)
- [fp64](https://typeshade.dev/ko/guide/internals/fp64/)
- [GLSL 셰이더 옮기기](https://typeshade.dev/ko/guide/internals/migrating-a-glsl-shader/)

## 함께 보기

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

## 소스

[`src/core/ir/node.ts`, 830행](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L830), 커밋 af54ddad5 기준
