lexical_write_float/
float.rs

1//! Extended helper trait for generic float types.
2//!
3//! This adds cache types and other helpers for extended-precision work.
4
5#![doc(hidden)]
6
7#[cfg(not(feature = "compact"))]
8use crate::algorithm::DragonboxFloat;
9#[cfg(feature = "compact")]
10use crate::compact::GrisuFloat;
11#[cfg(feature = "f16")]
12use lexical_util::bf16::bf16;
13use lexical_util::extended_float::ExtendedFloat;
14#[cfg(feature = "f16")]
15use lexical_util::f16::f16;
16
17/// Alias with ~80 bits of precision, 64 for the mantissa and 16 for exponent.
18/// This exponent is biased, and if the exponent is negative, it represents
19/// a value with a bias of `i32::MIN + F::EXPONENT_BIAS`.
20pub type ExtendedFloat80 = ExtendedFloat<u64>;
21
22/// Helper trait to add more float characteristics for parsing floats.
23#[cfg(feature = "compact")]
24pub trait RawFloat: GrisuFloat {}
25
26#[cfg(not(feature = "compact"))]
27pub trait RawFloat: DragonboxFloat {}
28
29impl RawFloat for f32 {
30}
31impl RawFloat for f64 {
32}
33#[cfg(feature = "f16")]
34impl RawFloat for f16 {
35}
36#[cfg(feature = "f16")]
37impl RawFloat for bf16 {
38}