Fix bad validation math
This commit is contained in:
parent
508f673873
commit
9c92d93ca4
|
@ -56,7 +56,7 @@ module Algebraic = {
|
|||
| #Subtract => Ok(a -. b)
|
||||
| #Multiply => Ok(a *. b)
|
||||
| #Power =>
|
||||
if a > 0.0 {
|
||||
if a >= 0.0 {
|
||||
Ok(a ** b)
|
||||
} else {
|
||||
Error(ComplexNumberError)
|
||||
|
@ -68,7 +68,10 @@ module Algebraic = {
|
|||
Error(DivisionByZeroError)
|
||||
}
|
||||
| #Logarithm =>
|
||||
if a > 0.0 && b > 0.0 {
|
||||
if b == 1. {
|
||||
Error(DivisionByZeroError)
|
||||
}
|
||||
else if a > 0.0 && b > 0.0 {
|
||||
Ok(log(a) /. log(b))
|
||||
} else {
|
||||
Error(ComplexNumberError)
|
||||
|
|
Loading…
Reference in New Issue
Block a user