Prevent exp underflow.

This commit is contained in:
Stephen Chung 2021-05-23 11:54:40 +08:00
parent d07d4d295d
commit 98a232cb8c

View File

@ -319,6 +319,8 @@ mod decimal_functions {
if cfg!(not(feature = "unchecked")) { if cfg!(not(feature = "unchecked")) {
if x > Decimal::from_parts(117578, 0, 0, false, 4) { if x > Decimal::from_parts(117578, 0, 0, false, 4) {
Err(make_err(format!("Exponential overflow: e ** {}", x,))) Err(make_err(format!("Exponential overflow: e ** {}", x,)))
} else if x < Decimal::from_parts(8, 0, 0, true, 0) {
Err(make_err(format!("Exponential underflow: e ** {}", x,)))
} else { } else {
Ok(x.exp()) Ok(x.exp())
} }