Skip to content

Commit 822cc0c

Browse files
committed
Fix x.powu(0)
1 parent e9e01f1 commit 822cc0c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/maths.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ impl MathematicalOps for Decimal {
227227
}
228228

229229
fn checked_powu(&self, exp: u64) -> Option<Decimal> {
230+
if exp == 0 {
231+
return Some(Decimal::ONE);
232+
}
230233
if self.is_zero() {
231234
return Some(Decimal::ZERO);
232235
}
@@ -235,7 +238,7 @@ impl MathematicalOps for Decimal {
235238
}
236239

237240
match exp {
238-
0 => Some(Decimal::ONE),
241+
0 => unreachable!(),
239242
1 => Some(*self),
240243
2 => self.checked_mul(*self),
241244
// Do the exponentiation by multiplying squares:

0 commit comments

Comments
 (0)