Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 6f0aae8

Browse files
committed
Rename Float::exp to Float::ex
Our function to get the exponent conflicts with the inherent `exp` function for `e^x`. Rename `exp` to `ex` to avoid confusion and usage problems.
1 parent 8f2a9ae commit 6f0aae8

File tree

6 files changed

+10
-11
lines changed

6 files changed

+10
-11
lines changed

etc/function-definitions.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@
206206
},
207207
"exp": {
208208
"sources": [
209-
"src/math/exp.rs",
210-
"src/math/support/float_traits.rs"
209+
"src/math/exp.rs"
211210
],
212211
"type": "f64"
213212
},

src/math/generic/fma.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ where
249249
let xy: B = x.widen() * y.widen();
250250
let mut result: B = xy + z.widen();
251251
let mut ui: B::Int = result.to_bits();
252-
let re = result.exp();
252+
let re = result.ex();
253253
let zb: B = z.widen();
254254

255255
let prec_diff = B::SIG_BITS - F::SIG_BITS;
@@ -318,15 +318,15 @@ impl<F: Float> Norm<F> {
318318

319319
fn from_float(x: F) -> Self {
320320
let mut ix = x.to_bits();
321-
let mut e = x.exp() as i32;
321+
let mut e = x.ex() as i32;
322322
let neg = x.is_sign_negative();
323323
if e == 0 {
324324
// Normalize subnormals by multiplication
325325
let scale_i = F::BITS - 1;
326326
let scale_f = F::from_parts(false, scale_i + F::EXP_BIAS, F::Int::ZERO);
327327
let scaled = x * scale_f;
328328
ix = scaled.to_bits();
329-
e = scaled.exp() as i32;
329+
e = scaled.ex() as i32;
330330
e = if e == 0 {
331331
// If the exponent is still zero, the input was zero. Artifically set this value
332332
// such that the final `e` will exceed `ZERO_INF_NAN`.

src/math/generic/fmod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ pub fn fmod<F: Float>(x: F, y: F) -> F {
99
let one = F::Int::ONE;
1010
let mut ix = x.to_bits();
1111
let mut iy = y.to_bits();
12-
let mut ex = x.exp().signed();
13-
let mut ey = y.exp().signed();
12+
let mut ex = x.ex().signed();
13+
let mut ey = y.ex().signed();
1414
let sx = ix & F::SIGN_MASK;
1515

1616
if iy << 1 == zero || y.is_nan() || ex == F::EXP_SAT as i32 {

src/math/generic/rint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use super::super::support::{FpResult, Round};
88
/// applicable.
99
pub fn rint_round<F: Float>(x: F, _round: Round) -> FpResult<F> {
1010
let toint = F::ONE / F::EPSILON;
11-
let e = x.exp();
11+
let e = x.ex();
1212
let positive = x.is_sign_positive();
1313

1414
// On i386 `force_eval!` must be used to force rounding via storage to memory. Otherwise,

src/math/generic/sqrt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ where
109109
ix = scaled.to_bits();
110110
match top {
111111
Exp::Shifted(ref mut v) => {
112-
*v = scaled.exp();
112+
*v = scaled.ex();
113113
*v = (*v).wrapping_sub(F::SIG_BITS);
114114
}
115115
Exp::NoShift(()) => {

src/math/support/float_traits.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ pub trait Float:
128128
}
129129

130130
/// Returns the exponent, not adjusting for bias, not accounting for subnormals or zero.
131-
fn exp(self) -> u32 {
131+
fn ex(self) -> u32 {
132132
u32::cast_from(self.to_bits() >> Self::SIG_BITS) & Self::EXP_SAT
133133
}
134134

135135
/// Extract the exponent and adjust it for bias, not accounting for subnormals or zero.
136136
fn exp_unbiased(self) -> i32 {
137-
self.exp().signed() - (Self::EXP_BIAS as i32)
137+
self.ex().signed() - (Self::EXP_BIAS as i32)
138138
}
139139

140140
/// Returns the significand with no implicit bit (or the "fractional" part)

0 commit comments

Comments
 (0)