Tour of WGSL

Numeric Literals

A WGSL numeric literal is a constant-expression representing a number. It can optionally have a suffix.

If it does not have a suffix, then its value is of an abstract-numeric type:

  • An unsuffixed literal with a decimal point (1.2) or exponent (1e2) is of type abstract-float.
  • Otherwise the literal is an abstract-int.

Adding a suffix to a numeric literal forces the value to be in a specific type:

SuffixType
ii32
uu32
ff32