Skip to content

Commit

Permalink
Remove negative number check from float sqrt
Browse files Browse the repository at this point in the history
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
ollie27 committed Jan 4, 2020
1 parent cd8377d commit a35b423
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 a35b423

Please sign in to comment.