lib-misc-utils · crate
half
Kinogaki's own half, published under the crates.io name so the frozen naga resolves to it through [patch.crates-io].
- Repository
- lib-misc-utils (kinogaki/lib-misc-utils)
- Folder
libs/lib-misc-utils/crates/half- Source
- 4 files, 1,039 lines
- Tests
- 1 file, 283 lines
What it is
Kinogaki's own half, published under the crates.io name so the frozen naga resolves to it through [patch.crates-io]. It is not upstream half: it has the IEEE 754 binary16 type f16 with what naga calls (its literals and constant folding), and with the num-traits feature our num-traits implementations for it.
Conversions are bit-exact IEEE 754 (round to nearest, ties to even; NaN stays NaN with its payload's top bits and the quiet bit set), checked over all 65,536 values and every rounding boundary (tests/conversions.rs). Arithmetic computes in f32 and rounds once to f16; for +, -, ×, ÷ and % that is the correctly rounded binary16 result (f32 has more than twice binary16's precision plus two bits, so the double rounding is harmless).
Depends on
| Crate | Repository | As | What it is |
|---|---|---|---|
num-traits | lib-misc-utils | normal | Kinogaki's own numeric traits, published under the crates.io name num-traits so the frozen naga and our half resolve to it through [patch.crates-io]. |
Third-party
None.
Used by
None.
Third-party crates using it
Modules
convert(private)Bit-level conversions between binary16 and binary32/binary64.131 linesf16_type(private)The binary16 type.412 linesnum_traits_impls(private)Our num-traits forf16.480 lines
Public types and traits
At the crate root
Structs f16
By module: 1 public type and trait in 1 module
f16_type f16
