sign()
Function in Builtins
sign(x): -1, 0 or 1 per component, according to the sign of x.
import { sign } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
const sign: <K extends "i32" | FloatKey | `vec${number}<i32>`>( x: ReadonlyNode<K>,) => Node<K>Parameters
xReadonlyNode<K>
Return value
Node<K>
Examples
Example
import { fn, sign, f32T } from 'typeshade'
const dir = fn('dir', { x: f32T }, ({ x }) => sign(x))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
Source
src/core/ir/node.ts, line 1528, at commit 26de7be8