sign
On this page

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

x ReadonlyNode<K>

Return value

Node<K>

Examples

Example

import { fn, sign, f32T } from 'typeshade'
const dir = fn('dir', { x: f32T }, ({ x }) => sign(x))

Targets

TargetSupportNotes
WGSL (WebGPU) Supported

sign(x).

GLSL ES 3.00 (WebGL2) Supported

sign(x).

CPU oracle Supported

Evaluated in f64 by the oracle.

In the guide

Source

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

Edit this page Report a problem