Skip to content

Commit a35b423

Browse files
committed
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

+1-1
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

+1-1
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)