Remove negative number check from float sqrt

It hasn't been UB to pass negative numbers to sqrt since https://reviews.llvm.org/D28797 which was included in LLVM 5.
This commit is contained in:
Oliver Middleton 2020-01-04 23:44:19 +00:00
parent cd8377d37e
commit a35b4234df
2 changed files with 2 additions and 2 deletions

View File

@ -376,7 +376,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[inline] #[inline]
pub fn sqrt(self) -> f32 { pub fn sqrt(self) -> f32 {
if self < 0.0 { NAN } else { unsafe { intrinsics::sqrtf32(self) } } unsafe { intrinsics::sqrtf32(self) }
} }
/// Returns `e^(self)`, (the exponential function). /// Returns `e^(self)`, (the exponential function).

View File

@ -342,7 +342,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[inline] #[inline]
pub fn sqrt(self) -> f64 { pub fn sqrt(self) -> f64 {
if self < 0.0 { NAN } else { unsafe { intrinsics::sqrtf64(self) } } unsafe { intrinsics::sqrtf64(self) }
} }
/// Returns `e^(self)`, (the exponential function). /// Returns `e^(self)`, (the exponential function).