max()
Function in Builtins
max(a, b): component-wise maximum, the partner of min(/api/min/).
import { max } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
const max: <K extends FloatKey | Float64Key | IntKey>( a: ReadonlyNode<K>, b: NoInfer<ArithArg<K>>,) => Node<K>Parameters
aReadonlyNode<K>bNoInfer<ArithArg<K>>
Return value
Node<K>
Description
b may be a scalar
broadcast against a vector a. A common floor idiom is max(x, f32(1e-6)), which keeps a
divisor or a sqrt or log argument off zero without a branch.
Examples
Example
import { fn, max, f32, f32T } from 'typeshade'
const safe = fn('safe', { x: f32T }, ({ x }) => max(x, f32(1e-6)))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
See also
Source
src/core/ir/node.ts, line 1650, at commit 26de7be8