ES2025 added Float16Array, getFloat16()/setFloat16() on DataView and Math.f16round() (Baseline 2025; see Floating-Point Pitfalls). A half-precision float has 1 sign, 5 exponent and 10 fraction bits: half the memory of Float32Array, a maximum of 65504 and about four significant digits. WebGPU and WebGL textures and machine-learning weights use this format, so JavaScript can now fill their buffers directly.
const weights = new Float32Array([0.1, -1.5, 3.14159, 70000]);
const half = new Float16Array(weights); // converts each element
console.log(weights.byteLength, half.byteLength, half);
const dv = new DataView(half.buffer);
console.log(dv.getFloat16(2, true), dv.getUint16(2, true).toString(2).padStart(16, '0'));16 8 Float16Array(4) [ 0.0999755859375, -1.5, 3.140625, Infinity ] -1.5 1011111000000000
Use half precision for storage and transfer, not arithmetic: 70000 overflowed to Infinity. Not every CPU converts float16 natively, so measure before replacing Float32Array in hot code.