Files
scriptc/tests/diagnostics/dataview.ts
T
Chris Tate 32061e8ba3 Add Float16Array
Float16Array is a native typed-array kind with IEEE 754 binary16 storage.
Stores round the number to nearest-even in one step from the double, as
Node does, including overflow to Infinity, subnormals, -0 and NaN; reads
widen exactly. The runtime converts with integer operations, so no target
needs half-precision hardware or compiler-rt support.

Construction, element reads and writes, ArrayBuffer views, fill, set,
subarray, slice, both sort orders, constructor values and checked-dynamic
storage work as for the other typed arrays. Math.f16round,
DataView.prototype.getFloat16 and setFloat16, and util.types.isFloat16Array
compile.
2026-10-17 22:45:32 -05:00

9 lines
316 B
TypeScript

// Stored ArrayBuffers and DataViews lower, Float16 accessors included;
// detached accessor methods remain unsupported.
const buffer = new ArrayBuffer(16);
const view = new DataView(buffer);
view.setFloat16(0, 1.5);
console.log(view.getFloat16(0));
const getter = view.getFloat16;
// End of the diagnostic fixture.