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