diff --git a/decTest/exp.decTest b/decTest/exp.decTest
index 8385dcde..74fdbcaf 100644
--- a/decTest/exp.decTest
+++ b/decTest/exp.decTest
@@ -540,6 +540,7 @@ expx1200 exp 1 -> 2.718281828459045235360287471352662 Inexact Rounded
Precision: 34
maxExponent: 6144
minExponent: -6143
+clamp: 1
expx1201 exp 309.5948855821510212996700645087188 -> 2.853319692901387521201738015050724E+134 Inexact Rounded
expx1202 exp 9.936543068706211420422803962680164 -> 20672.15839203171877476511093276022 Inexact Rounded
expx1203 exp 6.307870323881505684429839491707908 -> 548.8747777054637296137277391754665 Inexact Rounded
diff --git a/src/bin/run-test.rs b/src/bin/run-test.rs
index 72e0bba0..f9a07219 100644
--- a/src/bin/run-test.rs
+++ b/src/bin/run-test.rs
@@ -494,6 +494,7 @@ fn run_test<'a>(env: &Environment, test: Test<'a>) -> TestResult<'a> {
&test);
}
Op::Divide(a, b) => simple_op!(test, value = div(a, b)),
+ Op::Exp(a) => simple_op!(test, value = exp(a)),
Op::Fma(a, b, c) => simple_op!(test, value = mul_add(a, b, c)),
Op::Invert(a) => simple_op!(test, value = not(a)),
Op::LogB(a) => simple_op!(test, value = logb(a)),
diff --git a/src/dec128.rs b/src/dec128.rs
index 6841640a..bec2e1af 100644
--- a/src/dec128.rs
+++ b/src/dec128.rs
@@ -617,13 +617,11 @@ impl d128 {
/// respectively). Inexact results will almost always be correctly rounded, but may be up to 1
/// ulp (unit in last place) in error in rare cases. This is a mathematical function; the
/// 106 restrictions on precision and range apply as described above.
- pub fn exp>(mut self, exp: O) -> d128 {
+ pub fn exp(mut self) -> d128 {
d128::with_context(|ctx| unsafe {
let mut num_self: decNumber = uninitialized();
- let mut num_exp: decNumber = uninitialized();
decimal128ToNumber(&self, &mut num_self);
- decimal128ToNumber(exp.as_ref(), &mut num_exp);
- decNumberExp(&mut num_self, &num_self, &num_exp, ctx);
+ decNumberExp(&mut num_self, &num_self, ctx);
*decimal128FromNumber(&mut self, &num_self, ctx)
})
}
@@ -948,7 +946,6 @@ extern "C" {
ctx: *mut Context)
-> *mut decNumber;
fn decNumberExp(res: *mut decNumber,
- lhs: *const decNumber,
rhs: *const decNumber,
ctx: *mut Context)
-> *mut decNumber;
@@ -1093,4 +1090,9 @@ mod tests {
assert_eq!(d128::from_str(&(::std::u64::MIN).to_string()).unwrap(),
d128::from(::std::u64::MIN));
}
+
+ #[test]
+ fn math_op() {
+ assert_eq!(d128!(1), d128!(1).ln().exp());
+ }
}