Skip to content

Commit

Permalink
Refactor collapsible_if
Browse files Browse the repository at this point in the history
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
  • Loading branch information
wcampbell0x2a committed Oct 13, 2020
1 parent abbdec3 commit 096722f
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions library/std/src/f64.rs
Expand Up @@ -920,22 +920,20 @@ impl f64 {
fn log_wrapper<F: Fn(f64) -> f64>(self, log_fn: F) -> f64 {
if !cfg!(any(target_os = "solaris", target_os = "illumos")) {
log_fn(self)
} else {
if self.is_finite() {
if self > 0.0 {
log_fn(self)
} else if self == 0.0 {
Self::NEG_INFINITY // log(0) = -Inf
} else {
Self::NAN // log(-n) = NaN
}
} else if self.is_nan() {
self // log(NaN) = NaN
} else if self > 0.0 {
self // log(Inf) = Inf
} else if self.is_finite() {
if self > 0.0 {
log_fn(self)
} else if self == 0.0 {
Self::NEG_INFINITY // log(0) = -Inf
} else {
Self::NAN // log(-Inf) = NaN
Self::NAN // log(-n) = NaN
}
} else if self.is_nan() {
self // log(NaN) = NaN
} else if self > 0.0 {
self // log(Inf) = Inf
} else {
Self::NAN // log(-Inf) = NaN
}
}
}

0 comments on commit 096722f

Please sign in to comment.