Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a35b423

Browse files
committedJan 4, 2020
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.
1 parent cd8377d commit a35b423

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed
 

‎src/libstd/f32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ impl f32 {
376376
#[stable(feature = "rust1", since = "1.0.0")]
377377
#[inline]
378378
pub fn sqrt(self) -> f32 {
379-
if self < 0.0 { NAN } else { unsafe { intrinsics::sqrtf32(self) } }
379+
unsafe { intrinsics::sqrtf32(self) }
380380
}
381381

382382
/// Returns `e^(self)`, (the exponential function).

‎src/libstd/f64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl f64 {
342342
#[stable(feature = "rust1", since = "1.0.0")]
343343
#[inline]
344344
pub fn sqrt(self) -> f64 {
345-
if self < 0.0 { NAN } else { unsafe { intrinsics::sqrtf64(self) } }
345+
unsafe { intrinsics::sqrtf64(self) }
346346
}
347347

348348
/// Returns `e^(self)`, (the exponential function).

0 commit comments

Comments
 (0)
Please sign in to comment.