#const-generics #f16 #bfloat16

nightly minifloat

Emulate various minifloats with const generics

7 releases

0.1.6 May 22, 2024
0.1.5 May 15, 2024

#940 in Math

Download history 14/week @ 2024-07-23 10/week @ 2024-07-30 6/week @ 2024-09-24

430 downloads per month

MPL-2.0 license

53KB
1K SLoC

minifloat

Crates.io Documentation

Rust const generic library for minifloats

This crate provides emulation of minifloats up to 16 bits. This is done with two generic structs, F8 and F16, which take up to 8 and 16 bits of storage respectively. Many parameters are configurable, including

  • Exponent width
  • Significand (mantissa) precision
  • (F8-only) Exponent bias
  • (F8-only) NaN encodings: IEEE, FN, or FNUZ

Note that there is always a sign bit, so F8<4, 3> already uses up all 8 bits: 1 sign bit, 4 exponent bits, and 3 significand bits.


lib.rs:

A const generic library for minifloats

This crate provides emulation of minifloats up to 16 bits. This is done with two generic structs, [F8] and [F16], which take up to 8 and 16 bits of storage respectively. Many parameters are configurable, including

  • Exponent width
  • Significand (mantissa) precision
  • ([F8]-only) Exponent bias
  • ([F8]-only) NaN encodings: IEEE, FN, or FNUZ

Note that there is always a sign bit, so [F8<4, 3>] already uses up all 8 bits: 1 sign bit, 4 exponent bits, and 3 significand bits.

Dependencies

~150KB