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