Skip to content

Commit

Permalink
(-inf).ln() should return nan, not -inf (#1485)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaida-Amethyst authored Jan 16, 2025
1 parent 2de46fa commit 8d49ac3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions double/log.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ fn frexp(f : Double) -> (Double, Int) {
/// }
/// ```
pub fn ln(self : Double) -> Double {
if self.is_nan() || self.is_inf() {
return self
} else if self < 0.0 {
if self < 0.0 {
return not_a_number
} else if self.is_nan() || self.is_inf() {
return self
} else if self == 0.0 {
return neg_infinity
}
Expand Down Expand Up @@ -185,7 +185,7 @@ test "log2 log10" {
test "ln" {
assert_true!(not_a_number.ln().is_nan())
assert_true!(infinity.ln().is_pos_inf())
assert_true!(neg_infinity.ln().is_neg_inf())
assert_true!(neg_infinity.ln().is_nan())
assert_true!((-1.0).ln().is_nan())
assert_true!(0.0.ln().is_neg_inf())
assert_true!((-0.0).ln().is_neg_inf())
Expand Down

0 comments on commit 8d49ac3

Please sign in to comment.