Skip to content

Commit

Permalink
Rollup merge of rust-lang#67879 - ollie27:float_sqrt_neg, r=rkruppe
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dylan-DPC authored Jan 5, 2020
2 parents 21d9a09 + a35b423 commit 7db8e4a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/libstd/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ impl f32 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
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).
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl f64 {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
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).
Expand Down

0 comments on commit 7db8e4a

Please sign in to comment.