mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
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:
parent
cd8377d37e
commit
a35b4234df
@ -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).
|
||||||
|
@ -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).
|
||||||
|
Loading…
Reference in New Issue
Block a user