Skip to main content

FloatFormat

Trait FloatFormat 

Source
pub trait FloatFormat: Copy {
    const EXP_BITS: u32;
    const MAN_BITS: u32;
    const MAX_NORMAL: f32;
    const NAME: &'static str;
    const BITS: u32 = _;

    // Provided method
    fn quantize(x: f32) -> f32 { ... }
}
Expand description

A compile-time-known binary float format.

Required Associated Constants§

Source

const EXP_BITS: u32

Exponent bits.

Source

const MAN_BITS: u32

Explicit mantissa bits.

Source

const MAX_NORMAL: f32

Largest finite magnitude (format-specific: e.g. 448 for E4M3, 6 for E2M1).

Source

const NAME: &'static str

Canonical spec string ("f8e4m3", "nvf4", …).

Provided Associated Constants§

Source

const BITS: u32 = _

Total bits (1 + EXP_BITS + MAN_BITS).

Provided Methods§

Source

fn quantize(x: f32) -> f32

Round x to this format’s grid.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl FloatFormat for Bf16

Source§

const EXP_BITS: u32 = 8

Source§

const MAN_BITS: u32 = 7

Source§

const MAX_NORMAL: f32 = 3.3895314e38

Source§

const NAME: &'static str = "bf16"

Source§

impl FloatFormat for F6E3M2

Source§

const EXP_BITS: u32 = 3

Source§

const MAN_BITS: u32 = 2

Source§

const MAX_NORMAL: f32 = 28.0

Source§

const NAME: &'static str = "f6e3m2"

Source§

impl FloatFormat for F8E4M3

Source§

const EXP_BITS: u32 = 4

Source§

const MAN_BITS: u32 = 3

Source§

const MAX_NORMAL: f32 = 448.0

Source§

const NAME: &'static str = "f8e4m3"

Source§

impl FloatFormat for F8E5M2

Source§

const EXP_BITS: u32 = 5

Source§

const MAN_BITS: u32 = 2

Source§

const MAX_NORMAL: f32 = 57344.0

Source§

const NAME: &'static str = "bf8"

Source§

impl FloatFormat for F16

Source§

const EXP_BITS: u32 = 5

Source§

const MAN_BITS: u32 = 10

Source§

const MAX_NORMAL: f32 = 65504.0

Source§

const NAME: &'static str = "f16"

Source§

impl FloatFormat for Nvf4

Source§

const EXP_BITS: u32 = 2

Source§

const MAN_BITS: u32 = 1

Source§

const MAX_NORMAL: f32 = 6.0

Source§

const NAME: &'static str = "nvf4"