Skip to content

Commit c69c29b

Browse files
committed
Auto merge of #27948 - wthrowe:f64-sqrt, r=alexcrichton
This fixes a reappearance of bug #9987 introduced in 1ddee80, which caused f64::tests::test_sqrt_domain to fail (at least on some systems).
2 parents 568b13e + 5e9008d commit c69c29b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/libstd/num/f64.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,11 @@ impl f64 {
454454
#[stable(feature = "rust1", since = "1.0.0")]
455455
#[inline]
456456
pub fn sqrt(self) -> f64 {
457-
unsafe { intrinsics::sqrtf64(self) }
457+
if self < 0.0 {
458+
NAN
459+
} else {
460+
unsafe { intrinsics::sqrtf64(self) }
461+
}
458462
}
459463

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

0 commit comments

Comments
 (0)