Fix bad validation math

This commit is contained in:
Sam Nolan 2022-04-22 17:21:45 -04:00
parent 508f673873
commit 9c92d93ca4

View File

@ -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)