pow
On this page

pow()

Function in Builtins

pow(a, b): a raised to the power b, component-wise.

import { pow } from 'typeshade'

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

Syntax

function pow<K extends FloatKey>(a: ReadonlyNode<K>, b: NoInfer<ArithArg<K>>): Node<K>;
function pow(a: number, b: ReadonlyNode<'f32'>): Node<'f32'>;

Parameters

a ReadonlyNode<K>
b NoInfer<ArithArg<K>>

Return value

Node<K>

Description

A JS number b lifts to the kind of a, so pow(z, 4) emits pow(z, 4.0) for an f32 base. WGSL requires a and b to have the same type, so a vector a needs a vector b; a scalar b against a vector a passes the type check here and is rejected by the WGSL compiler.

Targets

TargetSupportNotes
WGSL (WebGPU) Supported

pow(a, b).

GLSL ES 3.00 (WebGL2) Supported

pow(a, b).

CPU oracle Supported

Evaluated in f64 by the oracle.

In the guide

Source

src/core/ir/node.ts, line 1658, at commit 26de7be8

Edit this page Report a problem