Like in the JS API, double
(aka JavaScript's native Number
type) is used in several places as a supertype of various numeric values. Such a value will be numerically downcast to the appropriate subtype depending how it is used, as specified in the JS API spec.
f32
/u32
/i32
f32
.bool
/f32
/u32
/i32
/f16
and possibly more).Floating-point-typed (float
/double
) values which are nullable or optional use NaN
to represent the null value. A value value
represents the null value iff isnan(value) != 0
. (Do not use an equality check with a NaN
constant, because NaN == NaN
is false.)
Infinities are invalid. See Non-Finite Float Value Errors.
The JavaScript API does not allow non-finite floating-point values (it throws a TypeError
).
In webgpu.h
, a value is finite iff isfinite(value) != 0
. Using a non-finite value (aside from NaN
for a Nullable Floating-Point Type) results in a validation Device Error, except on Wasm-on-JS targets where a TypeError
thrown by JS may be passed unhandled, interrupting Wasm execution.