about summary refs log tree commit diff
path: root/src/etc/test-float-parse
diff options
context:
space:
mode:
authorTrevor Gross <tmgross@umich.edu>2024-12-09 09:25:22 +0000
committerTrevor Gross <tmgross@umich.edu>2025-03-02 09:35:42 +0000
commit19a909ae0e9f923db2da0fc10264a75b7aa5ad99 (patch)
tree3d018f914abdd35148b660f36f222240d453b85b /src/etc/test-float-parse
parent6c34daff57101922dc97e1860bf5940ea88d3906 (diff)
downloadrust-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.rs6
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.
 ///