f32
이 페이지에서

f32()

함수, 값 분류

An f32 literal node.

import { f32 } from 'typeshade'

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

구문

function f32(v: number): Node<'f32'>;
function f32(x: ReadonlyNode<ScalarCastSource>): Node<'f32'>;

매개변수

v number

반환값

Node<'f32'>

예외

TypeError

v is neither a JS number nor a scalar node.

SD0116

SD0116 when the node operand is not a scalar.

설명

Most bare-number operands lift to f32 on their own (x.add(1) emits + 1.0 for an f32 x), so this is needed only where a standalone f32 value is wanted outside an operand position: a module-level const, a default argument.

A Node argument is a cast instead, the spelling WGSL and the "use typeshade" surface both write: f32(i) converts, and is the free-function twin of i.f32(). It builds what toF32 builds, so the two spellings share one emit. The operand is bounded to a scalar, which closes a hole both surfaces had: f32(someVec3) type-checked and emitted f32(v), which no target compiles.

예제

예제

import { f32 } from 'typeshade'
const half = f32(0.5) // Node<'f32'>

대상별 지원

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

f32(a).

GLSL ES 3.00 (WebGL2) 지원

float(a).

CPU 오라클 지원

Evaluated in f64 by the oracle.

관련 가이드

함께 보기

소스

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

이 페이지 편집 문제 보고