10 unstable releases (3 breaking)
| 0.4.2 | Aug 11, 2025 |
|---|---|
| 0.4.1 | Aug 9, 2025 |
| 0.3.0 | Jul 20, 2025 |
| 0.2.1 | Mar 14, 2025 |
| 0.1.1 | Oct 6, 2024 |
#265 in Rust patterns
88,528 downloads per month
Used in 101 crates
(16 directly)
91KB
2K
SLoC
float8: 8-bit floating point types for Rust
This crate provides 2 types:
F8E4M3: Sign + 4-bit exponent + 3-bit mantissa. More precise but less dynamic range.F8E5M2: Sign + 5-bit exponent + 2-bit mantissa. Less precise but more dynamic range (same exponent asf16).
Generally, this crate is modelled after the half crate, so it can be
used alongside and with minimal code changes.
- This crate provides
no_stdsupport - Requires Rust 1.70 or greater
Optional features
std- Enable features that depend on the Rust standard library.serde- Add support for theserdecrate withSerializeandDeserializetraits.num-traits- Implement traits fromnum-traitssuch asToPrimitive,FromPrimitive,AsPrimitive,Num,Float,FloatCore, andBounded.bytemuck- Implement traits frombytemuckincludingZeroableandPodzerocopy- Implement traits fromzerocopyincludingAsBytesandFromBytesrand_distr- Implement traits fromrand_distrincludingDistributionand othersrkyv- Enable zero-copy deserialization withrkyv.
Resources
- Good introduction: https://en.wikipedia.org/wiki/Minifloat
- Paper: https://arxiv.org/pdf/2209.05433
Dependencies
~1–4.5MB
~99K SLoC