https://github.com/junkwarrior87/half-float
Utility for converting 16-bit floats
https://github.com/junkwarrior87/half-float
float float16 floating-point half-float
Last synced: 9 months ago
JSON representation
Utility for converting 16-bit floats
- Host: GitHub
- URL: https://github.com/junkwarrior87/half-float
- Owner: junkwarrior87
- License: mit
- Created: 2023-02-18T13:14:34.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-19T14:12:14.000Z (about 3 years ago)
- Last Synced: 2025-05-30T12:37:18.740Z (10 months ago)
- Topics: float, float16, floating-point, half-float
- Language: TypeScript
- Homepage:
- Size: 51.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# half-float
Utility for converting 16-bit floats. Might be useful for dealing with some special image formats (e.g. `.exr` format).
## Install
```sh
npm i @goldfinger87/half-float
```
## Usage
```js
import { Float16 } from '@goldfinger87/half-float';
console.log(Float16.fromBits(0x3C00)); // ==> 1.0
console.log(Float16.fromBits(0x3C01)); // ==> 1.0009765625
```
## Roadmap
- `toBits` function for converting back from half-float to binary bits (i.e., unsigned 16-bit integer)
- unit tests
- wasm implementation
- gpu (batched) implementation
- benchmark