summaryrefslogtreecommitdiff
path: root/library/src
diff options
context:
space:
mode:
Diffstat (limited to 'library/src')
-rw-r--r--library/src/compute/calc.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/library/src/compute/calc.rs b/library/src/compute/calc.rs
index f4695675..d5166449 100644
--- a/library/src/compute/calc.rs
+++ b/library/src/compute/calc.rs
@@ -108,7 +108,11 @@ pub fn pow(
};
let result = match (base, exponent.v) {
- (Num::Int(a), Num::Int(b)) if b >= 0 => Num::Int(a.pow(b as u32)),
+ (Num::Int(a), Num::Int(b)) if b >= 0 => a
+ .checked_pow(b as u32)
+ .map(Num::Int)
+ .ok_or("the result is too large")
+ .at(args.span)?,
(a, Num::Int(b)) => Num::Float(a.float().powi(b as i32)),
(a, b) => Num::Float(a.float().powf(b.float())),
};