Last active
January 20, 2016 18:55
-
-
Save nbaksalyar/bf8f1eae0e1650db6a2d to your computer and use it in GitHub Desktop.
f64 implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl f64 { | |
// ... | |
#[stable(feature = "rust1", since = "1.0.0")] | |
#[inline] | |
pub fn ln(self) -> f64 { | |
if self.is_finite() { | |
if x > 0.0 { | |
return unsafe { intrinsics::logf64(self) } | |
} | |
return if x == 0.0 { | |
NEG_INFINITY // log(0) = -Inf | |
} else { | |
NAN // log(-ve) = NaN | |
} | |
} else if self.is_nan() { | |
self // log(NaN) = NaN | |
} else if x > 0.0 { | |
x // log(Inf) = Inf | |
} else { | |
return NAN // log(-Inf) = NaN | |
} | |
} | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl f64 { | |
// ... | |
#[stable(feature = "rust1", since = "1.0.0")] | |
#[inline] | |
pub fn ln(self) -> f64 { | |
unsafe { intrinsics::logf64(self) } | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment