GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - tc39/proposal-float16array: a proposal to add float16 TypedArrays to JavaScript

This repository was archived by the owner on May 24, 2025. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

13 Commits
13 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
spec.html
spec.html
 
 

Repository files navigation

Float16Array

A proposal to add float16 (aka half-precision or binary16) TypedArrays to JavaScript.

Status

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.

Implementations

This proposal is ready for engines to implement and ship. See this issue for current status of implementations.

Motivation

  • Explicit request from the Color on the Web CG, for their use case with float-backed canvases.
  • Useful for GPU operations, where full precision often isn't necessary and memory constraints are serious.
    • WebGPU supports float16. It exposes/consumes raw ArrayBuffers. When those contain 32-bit floats, the pattern is to wrap the buffer in new Float32Array(...); that doesn't work when they contain 16-bit floats.
    • Increasingly relevant with new tools like Stable Diffusion, where full-precision representations don't fit in VRAM on many machines.
  • WebGL/WebGL2 support float16.
    • WebGL's 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.
  • ARM and IA-32 and Intel® 64 architectures support float16 intrinsics.
    • In the C++23 specification, std::float16_t will be supported to call the CPU instructions.
  • Faking it in userland has serious performance costs.

Proposal

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.

Userland

@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.

About

a proposal to add float16 TypedArrays to JavaScript

tc39.es/proposal-float16array/

Resources

Readme

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

64 stars

Watchers

6 watching

Forks

5 forks
Report repository

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.