diff options
| author | Trevor Gross <tmgross@umich.edu> | 2024-12-09 09:25:22 +0000 |
|---|---|---|
| committer | Trevor Gross <tmgross@umich.edu> | 2025-03-02 09:35:42 +0000 |
| commit | 19a909ae0e9f923db2da0fc10264a75b7aa5ad99 (patch) | |
| tree | 3d018f914abdd35148b660f36f222240d453b85b /src/etc/test-float-parse | |
| parent | 6c34daff57101922dc97e1860bf5940ea88d3906 (diff) | |
| download | rust-19a909ae0e9f923db2da0fc10264a75b7aa5ad99.tar.gz rust-19a909ae0e9f923db2da0fc10264a75b7aa5ad99.zip | |
dec2flt: Refactor float traits
A lot of the magic constants can be turned into expressions. This reduces some code duplication. Additionally, add traits to make these operations fully generic. This will make it easier to support `f16` and `f128`.
Diffstat (limited to 'src/etc/test-float-parse')
| -rw-r--r-- | src/etc/test-float-parse/src/traits.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/etc/test-float-parse/src/traits.rs b/src/etc/test-float-parse/src/traits.rs index f5333d63b36..f7f5f5dd35b 100644 --- a/src/etc/test-float-parse/src/traits.rs +++ b/src/etc/test-float-parse/src/traits.rs @@ -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. /// |
