a proposal to add float16 TypedArrays to JavaScript
64
stars
13
commits
HTML
primary language
May 24, 2025
updated
A proposal to add float16 (aka half-precision or binary16) TypedArrays to JavaScript.
Authors: Kevin Gibbons
Champions: Leo Balter, Kevin Gibbons
This proposal is at Stage 4 of the TC39 process as of the February 2025 meeting: it is finished, has landed in ecma262, and is shipping in browsers. Any further discussion should happen elsewhere.
Spec text is available here.
This proposal is ready for engines to implement and ship. See this issue for current status of implementations.
new Float32Array(...); that doesn't work when they contain 16-bit floats.OES_texture_half_float extension and WebGL2 support float16 texture, and also both EXT_color_buffer_half_float extensions support float16 render target. They expose/consume Uint16Arrays; that is not easy to handle.std::float16_t will be supported to call the CPU instructions.This would add a new kind of TypedArray, Float16Array, to complement the existing Float32Array and Float64Array. It would also add two new methods on DataView for reading and setting float16 values, as getFloat16 and setFloat16, to complement the existing similar methods for working with full and double precision floats, as well as Math.f16round, to complement the existing Math.fround.
@petramoriken has a package implementing Float16Array which gets 100k+ downloads/week on npm. See that repository for examples of some of the limitations and downsides of trying to do this purely in userland - notably the impossibility of integrating correctly with other web platform features like WebGL's HALF_FLOAT buffers and structuredClone.
12 commits
1 commits
HTML
100.0%
a proposal to add float16 TypedArrays to JavaScript
64
stars
13
commits
HTML
primary language
May 24, 2025
updated
A proposal to add float16 (aka half-precision or binary16) TypedArrays to JavaScript.
Authors: Kevin Gibbons
Champions: Leo Balter, Kevin Gibbons
This proposal is at Stage 4 of the TC39 process as of the February 2025 meeting: it is finished, has landed in ecma262, and is shipping in browsers. Any further discussion should happen elsewhere.
Spec text is available here.
This proposal is ready for engines to implement and ship. See this issue for current status of implementations.
new Float32Array(...); that doesn't work when they contain 16-bit floats.OES_texture_half_float extension and WebGL2 support float16 texture, and also both EXT_color_buffer_half_float extensions support float16 render target. They expose/consume Uint16Arrays; that is not easy to handle.std::float16_t will be supported to call the CPU instructions.This would add a new kind of TypedArray, Float16Array, to complement the existing Float32Array and Float64Array. It would also add two new methods on DataView for reading and setting float16 values, as getFloat16 and setFloat16, to complement the existing similar methods for working with full and double precision floats, as well as Math.f16round, to complement the existing Math.fround.
@petramoriken has a package implementing Float16Array which gets 100k+ downloads/week on npm. See that repository for examples of some of the limitations and downsides of trying to do this purely in userland - notably the impossibility of integrating correctly with other web platform features like WebGL's HALF_FLOAT buffers and structuredClone.
12 commits
1 commits
HTML
100.0%