Math members

Math members

41 names

The Math members a shader may reach, each routed to a builtin or a literal.

The signature, the sentence and any message are the compiler's own text at commit af54ddad5.

Math.fround
Casts a number to f32 single-precision floating-point by inlining a literal value rounded to 32-bit precision.
Math.random
Not a GPU builtin: a call with no seed does not compile, because a shader has no random source.
Math.abs
Returns the absolute value of x.
Math.acos
Returns the arccosine of x (in radians).
Math.acosh
Returns the inverse hyperbolic cosine of x.
Math.asin
Returns the arcsine of x (in radians).
Math.asinh
Returns the inverse hyperbolic sine of x.
Math.atan
Returns the arctangent of x (in radians).
Math.atanh
Returns the inverse hyperbolic tangent of x.
Math.atan2
Returns the arctangent of y/x (in radians), using the signs of both arguments to determine the quadrant, taking arguments in the order (y, x).
Math.cbrt
Returns the cube root of x, computed as sign(x) * pow(abs(x), 1/3), for f32 scalars only.
Math.ceil
Returns the smallest integer not less than x.
Math.cos
Returns the cosine of x (in radians).
Math.cosh
Returns the hyperbolic cosine of x.
Math.exp
Returns the exponential function (e raised to the power of x).
Math.expm1
Returns e raised to the power of x minus 1, computed as exp(x) - 1, for f32 scalars only.
Math.floor
Returns the largest integer not greater than x.
Math.hypot
Returns the Euclidean length of the vector formed from 2 or 3 f32 scalar arguments, computed via length, for f32 scalars only.
Math.log
Returns the natural logarithm of x.
Math.log10
Returns the base-10 logarithm of x (log(x) times Math.LOG10E), for f32 scalars only.
Math.log1p
Returns the natural logarithm of (1 plus x), computed as log(x + 1), for f32 scalars only.
Math.log2
Returns the base-2 logarithm of x.
Math.max
Returns the greater of a and b.
Math.min
Returns the lesser of a and b.
Math.pow
Returns x raised to the power of y; x ** y is the same operation.
Math.round
Rounds x to the nearest integer, with halfway cases rounding to the nearest even integer.
Math.sign
Returns -1 if x is negative, 1 if positive, and 0 if zero.
Math.sin
Returns the sine of x (in radians).
Math.sinh
Returns the hyperbolic sine of x.
Math.sqrt
Returns the square root of x.
Math.tan
Returns the tangent of x (in radians).
Math.tanh
Returns the hyperbolic tangent of x.
Math.trunc
Returns x truncated toward zero.
Math.E
The mathematical constant e, inlined as a compile-time f32 literal (approximately 2.71828).
Math.LN10
The natural logarithm of 10, inlined as a compile-time f32 literal (approximately 2.30259).
Math.LN2
The natural logarithm of 2, inlined as a compile-time f32 literal (approximately 0.69315).
Math.LOG10E
The base-10 logarithm of e, inlined as a compile-time f32 literal (approximately 0.43429).
Math.LOG2E
The base-2 logarithm of e, inlined as a compile-time f32 literal (approximately 1.44270).
Math.PI
The mathematical constant π, inlined as a compile-time f32 literal (approximately 3.14159).
Math.SQRT1_2
The square root of 1/2, inlined as a compile-time f32 literal (approximately 0.70711).
Math.SQRT2
The square root of 2, inlined as a compile-time f32 literal (approximately 1.41421).

Names, declarations and descriptions come from the compiler language-service tables at the pinned commit. Builtin output spellings and stage rules are read from compiler code. The site supplies the groupings and explanations around these entries.

Edit this page Report a problem