Compare commits
No commits in common. "493ef7e2938ff151be102abca80b1314478f8f4e" and "22b399034f928c08e56765c6bdfb450ce4720a77" have entirely different histories.
493ef7e293
...
22b399034f
|
|
@ -1,9 +0,0 @@
|
||||||
# F8: 8-bit floats
|
|
||||||
|
|
||||||
<div class="warning">Not for production use!</div>
|
|
||||||
|
|
||||||
F8 is a toy software floating-point math library.
|
|
||||||
It provides an 8-bit floating point type `F8`, with 5 mantissa bits, 3 exponent bits, and no sign bit.
|
|
||||||
The format used resembles [IEEE 754] binary formats but stripped down to the bare necessities: the only special value supported is zero.
|
|
||||||
|
|
||||||
[IEEE 754]: https://en.wikipedia.org/wiki/IEEE_754
|
|
||||||
19
src/lib.rs
19
src/lib.rs
|
|
@ -31,22 +31,7 @@ const E_BIAS: u8 = E_STORAGE_MAX - E_MAX;
|
||||||
const M_MASK: u8 = M_STORAGE_MAX;
|
const M_MASK: u8 = M_STORAGE_MAX;
|
||||||
const E_MASK: u8 = E_STORAGE_MAX << M_BITS;
|
const E_MASK: u8 = E_STORAGE_MAX << M_BITS;
|
||||||
|
|
||||||
/// 8-bit unsigned binary floating-point type.
|
/// 8-bit unsigned binary floating-point type, with [`M_BITS`] mantissa bits and [`E_BITS`] exponent bits.
|
||||||
///
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
/// # Properties
|
|
||||||
///
|
|
||||||
/// * Mantissa width: 5 bits ([`M_BITS`])
|
|
||||||
/// * Exponent width: 3 bits ([`E_BITS`])
|
|
||||||
/// * Negative values: not supported
|
|
||||||
/// * Zero: special-cased
|
|
||||||
/// * Subnormals: not supported
|
|
||||||
/// * Infinity: not supported
|
|
||||||
/// * NaN: not supported
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)]
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct F8(u8);
|
pub struct F8(u8);
|
||||||
|
|
||||||
impl F8 {
|
|
||||||
pub const ZERO: Self = Self(0);
|
|
||||||
pub const ONE: Self = Self::merge(0, E_BIAS);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user