div()
Function in Builtins
a / b as a free function, for a literal numerator: div(1, x) is the reciprocal, and emits (1.0 / x).
import { div } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
function div<E extends string, N extends number>( a: ReadonlyNode<E>, b: ReadonlyNode<`vec${N}<${E}>`>,): Node<`vec${N}<${E}>`>;function div<K extends string>(a: ReadonlyNode<K>, b: ArithArg<K>): Node<K>;function div<K extends string>(a: number, b: ReadonlyNode<K>): Node<K>;Parameters
aReadonlyNode<E>bReadonlyNode<`vec${N}<${E}>`>
Return value
Node<`vec${N}<${E}>`>
Exceptions
TypeErrorboth operands are plain numbers.
Description
Whichever operand is a node types the other. Two bare numbers are rejected.
Examples
Example
import { fn, div, f32T } from 'typeshade'
const recip = fn('recip', { x: f32T }, ({ x }) => div(1, x))In the guide
See also
Source
src/core/ir/node.ts, line 1256, at commit 26de7be8