Rollup merge of #134063 - tgross35:dec2flt-refactoring, r=Noratrieb

dec2flt: Clean up float parsing modules

This is the first portion of my work adding support for parsing and printing `f16`. Changes in `float.rs` replace the magic constants with expressions and add some use of generics to better support the new float types. Everything else is related to documentation or naming; there are no functional changes in this PR.

This can be reviewed by commit.
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2025-03-05 21:46:31 +08:00 committed by GitHub
commit 9b8accbeb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 851 additions and 600 deletions

View file

@ -147,12 +147,12 @@ pub trait Float:
}
macro_rules! impl_float {
($($fty:ty, $ity:ty, $bits:literal);+) => {
($($fty:ty, $ity:ty);+) => {
$(
impl Float for $fty {
type Int = $ity;
type SInt = <Self::Int as Int>::Signed;
const BITS: u32 = $bits;
const BITS: u32 = <$ity>::BITS;
const MAN_BITS: u32 = Self::MANTISSA_DIGITS - 1;
const MAN_MASK: Self::Int = (Self::Int::ONE << Self::MAN_BITS) - Self::Int::ONE;
const SIGN_MASK: Self::Int = Self::Int::ONE << (Self::BITS-1);
@ -168,7 +168,7 @@ macro_rules! impl_float {
}
}
impl_float!(f32, u32, 32; f64, u64, 64);
impl_float!(f32, u32; f64, u64);
/// A test generator. Should provide an iterator that produces unique patterns to parse.
///