From ef00132996a9f50b3cfa4f2f69c143eee6c2975c Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 3 Jan 2025 02:56:34 +0000 Subject: [PATCH] Rename `EXP_MAX` to `EXP_SAT` "Maximum" is technically correct here with regards to what the bitpattern can represent, but it is not the numeric maximum value of the exponent which has a relationship with the bias. So, replace the maximum terminology with "saturated" to indicate it only means the full bitpattern. This change is more relevant to `libm` than `compiler-builtins`. --- src/float/add.rs | 2 +- src/float/div.rs | 2 +- src/float/extend.rs | 2 +- src/float/mod.rs | 9 ++++++--- src/float/mul.rs | 2 +- src/float/trunc.rs | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/float/add.rs b/src/float/add.rs index 743cc441..004ea3eb 100644 --- a/src/float/add.rs +++ b/src/float/add.rs @@ -14,7 +14,7 @@ where let bits = F::BITS.cast(); let significand_bits = F::SIG_BITS; - let max_exponent = F::EXP_MAX; + let max_exponent = F::EXP_SAT; let implicit_bit = F::IMPLICIT_BIT; let significand_mask = F::SIG_MASK; diff --git a/src/float/div.rs b/src/float/div.rs index c211faba..a461397e 100644 --- a/src/float/div.rs +++ b/src/float/div.rs @@ -107,7 +107,7 @@ where let significand_bits = F::SIG_BITS; // Saturated exponent, representing infinity - let exponent_sat: F::Int = F::EXP_MAX.cast(); + let exponent_sat: F::Int = F::EXP_SAT.cast(); let exponent_bias = F::EXP_BIAS; let implicit_bit = F::IMPLICIT_BIT; diff --git a/src/float/extend.rs b/src/float/extend.rs index a5d69864..a1a9b972 100644 --- a/src/float/extend.rs +++ b/src/float/extend.rs @@ -26,7 +26,7 @@ where let dst_bits = R::BITS; let dst_sign_bits = R::SIG_BITS; - let dst_inf_exp = R::EXP_MAX; + let dst_inf_exp = R::EXP_SAT; let dst_exp_bias = R::EXP_BIAS; let dst_min_normal = R::IMPLICIT_BIT; diff --git a/src/float/mod.rs b/src/float/mod.rs index 9ba447f9..6ee55950 100644 --- a/src/float/mod.rs +++ b/src/float/mod.rs @@ -51,11 +51,14 @@ pub(crate) trait Float: /// The bitwidth of the exponent. const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1; - /// The saturated value of the exponent (infinite representation), in the rightmost postiion. - const EXP_MAX: u32 = (1 << Self::EXP_BITS) - 1; + /// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite + /// representation. + /// + /// This is in the rightmost position, use `EXP_MASK` for the shifted value. + const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1; /// The exponent bias value. - const EXP_BIAS: u32 = Self::EXP_MAX >> 1; + const EXP_BIAS: u32 = Self::EXP_SAT >> 1; /// A mask for the sign bit. const SIGN_MASK: Self::Int; diff --git a/src/float/mul.rs b/src/float/mul.rs index 62895293..f0f261a2 100644 --- a/src/float/mul.rs +++ b/src/float/mul.rs @@ -14,7 +14,7 @@ where let bits = F::BITS; let significand_bits = F::SIG_BITS; - let max_exponent = F::EXP_MAX; + let max_exponent = F::EXP_SAT; let exponent_bias = F::EXP_BIAS; diff --git a/src/float/trunc.rs b/src/float/trunc.rs index c95e9c19..5efeac98 100644 --- a/src/float/trunc.rs +++ b/src/float/trunc.rs @@ -29,7 +29,7 @@ where let dst_zero = R::Int::ZERO; let dst_one = R::Int::ONE; let dst_bits = R::BITS; - let dst_inf_exp = R::EXP_MAX; + let dst_inf_exp = R::EXP_SAT; let dst_exp_bias = R::EXP_BIAS; let underflow_exponent: F::Int = (src_exp_bias + 1 - dst_exp_bias).cast();