i32()
Function in Values
An i32 literal node.
import { i32 } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
function i32(v: number): Node<'i32'>;function i32(x: ReadonlyNode<ScalarCastSource>): Node<'i32'>;Parameters
vnumber
Return value
Node<'i32'>
Exceptions
Description
Use it over the f32 default wherever a value must type-check as a
signed integer: array and loop indices, matchExpr and matchEnum scrutinees, texture
layer arguments.
A Node argument is a cast instead: i32(x) converts, the free-function twin of x.i32().
It builds what toI32 builds, and its operand is bounded to a scalar.
Examples
Example
import { i32 } from 'typeshade'
const zero = i32(0) // Node<'i32'>Targets
| Target | Support | Notes |
|---|---|---|
| WGSL (WebGPU) | Supported |
|
| GLSL ES 3.00 (WebGL2) | Supported |
|
| CPU oracle | Supported | Evaluated in f64 by the oracle. |
In the guide
See also
Source
src/core/ir/node.ts, line 994, at commit 26de7be8