u32
Function
Casts a number to u32 unsigned 32-bit integer by truncating toward zero.
The signature and the sentence under each name are the compiler's own text at commit 26de7be8.
Syntax
declare function u32(): u32declare function u32(x: number | bool): u32A number in a parameter or a return position is the scalar slot. The ambient file declares a GPU scalar as a branded number whose brand is optional, so a literal and any branded scalar both fill it.
type f32 = number & { readonly [f32Tag]?: true }
A declaration you write still needs a width, and a bare number on a field or a parameter is refused; the TypeScript constructs page carries that row with the compiler's own message.
Parameters
-
xoptionalnumber | bool
Return value
u32
Description
Literal values outside [0, 2^32-1] are a compile error; at runtime, out-of-range values wrap via two's-complement.
Targets
- WGSL
-
u32(a) - GLSL ES 3.00
-
uint(a)
Examples
fp64-mercator-tiles.tsjulia.tsmandelbrot.tsfbm-clouds.tsdomain-warp.tsraymarch-sphere.tsraymarch-boxes.tsmetaballs.tsocean.tsstarfield.tskaleidoscope.tsfp64-mandelbrot.tsfp64-julia.tsfp64-burning-ship.tsfp64-newton.tsfp64-mandelbrot-de.tstexture-array-lod.tscompute-reduction.tstwin-structs.shade.tsid-pick.shade.tstextured-quad.shade.tsstorage-texture.shade.tssample-branch.shade.tsmodule-const.shade.tspalette-const.shade.tsconvert-grid.shade.tsblock-scope.shade.tscutout.shade.tsbit-bump.shade.tsinteger-math.shade.tspacked-bytes.shade.tsclosures.shade.tshigher-order.shade.tsinferred-returns.shade.tsarray-methods.shade.tscapsule-corp-namek-class.shade.tsparticle-step.shade.tsgeneric-helpers.shade.tsclass-syntax.shade.tsrng-method.shade.tsclass-builder.shade.tsclass-parts.shade.tsrt-renderer-class.shade.tsseparable-blur.shade.tsfeedback-trail.shade.tsprivate-state.shade.tsatomic-histogram.shade.tsloop-reduction.shade.tsdomain-warp-twin.shade.tsocean-twin.shade.tsstarfield-twin.shade.tskaleidoscope-twin.shade.ts