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`.
This commit is contained in:
Trevor Gross 2025-01-03 02:56:34 +00:00
parent b47d3cc2f8
commit 7065cd0420
6 changed files with 11 additions and 8 deletions

View File

@ -14,7 +14,7 @@ where
let bits = F::BITS.cast(); let bits = F::BITS.cast();
let significand_bits = F::SIG_BITS; 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 implicit_bit = F::IMPLICIT_BIT;
let significand_mask = F::SIG_MASK; let significand_mask = F::SIG_MASK;

View File

@ -107,7 +107,7 @@ where
let significand_bits = F::SIG_BITS; let significand_bits = F::SIG_BITS;
// Saturated exponent, representing infinity // 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 exponent_bias = F::EXP_BIAS;
let implicit_bit = F::IMPLICIT_BIT; let implicit_bit = F::IMPLICIT_BIT;

View File

@ -26,7 +26,7 @@ where
let dst_bits = R::BITS; let dst_bits = R::BITS;
let dst_sign_bits = R::SIG_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_exp_bias = R::EXP_BIAS;
let dst_min_normal = R::IMPLICIT_BIT; let dst_min_normal = R::IMPLICIT_BIT;

View File

@ -51,11 +51,14 @@ pub(crate) trait Float:
/// The bitwidth of the exponent. /// The bitwidth of the exponent.
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1; const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
/// The saturated value of the exponent (infinite representation), in the rightmost postiion. /// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
const EXP_MAX: u32 = (1 << Self::EXP_BITS) - 1; /// 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. /// 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. /// A mask for the sign bit.
const SIGN_MASK: Self::Int; const SIGN_MASK: Self::Int;

View File

@ -14,7 +14,7 @@ where
let bits = F::BITS; let bits = F::BITS;
let significand_bits = F::SIG_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; let exponent_bias = F::EXP_BIAS;

View File

@ -29,7 +29,7 @@ where
let dst_zero = R::Int::ZERO; let dst_zero = R::Int::ZERO;
let dst_one = R::Int::ONE; let dst_one = R::Int::ONE;
let dst_bits = R::BITS; 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 dst_exp_bias = R::EXP_BIAS;
let underflow_exponent: F::Int = (src_exp_bias + 1 - dst_exp_bias).cast(); let underflow_exponent: F::Int = (src_exp_bias + 1 - dst_exp_bias).cast();