Skip to content

Commit eae08b2

Browse files
authored
Rollup merge of rust-lang#67879 - ollie27:float_sqrt_neg, r=rkruppe
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.
2 parents 59f8ba3 + a35b423 commit eae08b2

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)