mirror of https://github.com/rm-dr/daisy
Added check for negative powers
parent
8ca4ffd51f
commit
dae76f3d56
|
@ -171,6 +171,7 @@ fn operators() {
|
|||
good_expr("7", "3!+1");
|
||||
good_expr("18", "3!3");
|
||||
bad_expr("3.1!");
|
||||
bad_expr("0^(-1)");
|
||||
bad_expr("pi!");
|
||||
}
|
||||
|
||||
|
|
|
@ -460,6 +460,10 @@ impl Operator{
|
|||
return Err(EvalError::IncompatibleUnit);
|
||||
}
|
||||
|
||||
if va.is_zero() && vb.is_negative() {
|
||||
return Err(EvalError::ZeroDivision);
|
||||
}
|
||||
|
||||
let p = va.pow(vb);
|
||||
if p.is_nan() {return Err(EvalError::BadMath);}
|
||||
return Ok(Token::Number(p));
|
||||
|
|
Loading…
Reference in New Issue