Skip to content

Commit ef00132

Browse files
committed
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`.
1 parent 85604d9 commit ef00132

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

src/float/add.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ where
1414

1515
let bits = F::BITS.cast();
1616
let significand_bits = F::SIG_BITS;
17-
let max_exponent = F::EXP_MAX;
17+
let max_exponent = F::EXP_SAT;
1818

1919
let implicit_bit = F::IMPLICIT_BIT;
2020
let significand_mask = F::SIG_MASK;

src/float/div.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ where
107107

108108
let significand_bits = F::SIG_BITS;
109109
// Saturated exponent, representing infinity
110-
let exponent_sat: F::Int = F::EXP_MAX.cast();
110+
let exponent_sat: F::Int = F::EXP_SAT.cast();
111111

112112
let exponent_bias = F::EXP_BIAS;
113113
let implicit_bit = F::IMPLICIT_BIT;

src/float/extend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ where
2626

2727
let dst_bits = R::BITS;
2828
let dst_sign_bits = R::SIG_BITS;
29-
let dst_inf_exp = R::EXP_MAX;
29+
let dst_inf_exp = R::EXP_SAT;
3030
let dst_exp_bias = R::EXP_BIAS;
3131
let dst_min_normal = R::IMPLICIT_BIT;
3232

src/float/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,14 @@ pub(crate) trait Float:
5151
/// The bitwidth of the exponent.
5252
const EXP_BITS: u32 = Self::BITS - Self::SIG_BITS - 1;
5353

54-
/// The saturated value of the exponent (infinite representation), in the rightmost postiion.
55-
const EXP_MAX: u32 = (1 << Self::EXP_BITS) - 1;
54+
/// The saturated (maximum bitpattern) value of the exponent, i.e. the infinite
55+
/// representation.
56+
///
57+
/// This is in the rightmost position, use `EXP_MASK` for the shifted value.
58+
const EXP_SAT: u32 = (1 << Self::EXP_BITS) - 1;
5659

5760
/// The exponent bias value.
58-
const EXP_BIAS: u32 = Self::EXP_MAX >> 1;
61+
const EXP_BIAS: u32 = Self::EXP_SAT >> 1;
5962

6063
/// A mask for the sign bit.
6164
const SIGN_MASK: Self::Int;

src/float/mul.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ where
1414

1515
let bits = F::BITS;
1616
let significand_bits = F::SIG_BITS;
17-
let max_exponent = F::EXP_MAX;
17+
let max_exponent = F::EXP_SAT;
1818

1919
let exponent_bias = F::EXP_BIAS;
2020

src/float/trunc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ where
2929
let dst_zero = R::Int::ZERO;
3030
let dst_one = R::Int::ONE;
3131
let dst_bits = R::BITS;
32-
let dst_inf_exp = R::EXP_MAX;
32+
let dst_inf_exp = R::EXP_SAT;
3333
let dst_exp_bias = R::EXP_BIAS;
3434

3535
let underflow_exponent: F::Int = (src_exp_bias + 1 - dst_exp_bias).cast();

0 commit comments

Comments
 (0)