abs
이 페이지에서

abs()

함수, 내장 함수 분류

abs(x): absolute value, component-wise.

import { abs } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

const abs: <K extends FloatKey | Float64Key | IntKey>(
x: ReadonlyNode<K>,
) => Node<K>

매개변수

x ReadonlyNode<K>

반환값

Node<K>

설명

An unsigned operand takes the absU id rather than the portable abs one, because GLSL ES 3.00 has no abs(uint) overload and a WebGL2 driver refuses the call. The choice is divergentIntegerId, shared with the "use typeshade" front end so both authoring surfaces emit the same thing; every other operand keeps the portable spelling.

예제

예제

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

대상별 지원

대상지원비고
WGSL (WebGPU) 지원

abs(a). Over f64 operands the fp64 pass rewrites it into its df64 helper.

GLSL ES 3.00 (WebGL2) 지원

abs(a). Over f64 operands the fp64 pass rewrites it into its df64 helper.

CPU 오라클 지원

Evaluated in f64 by the oracle.

관련 가이드

소스

src/core/ir/node.ts, 1472행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고