File tree 2 files changed +6
-2
lines changed
2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -324,18 +324,20 @@ impl f32 {
324
324
325
325
/// Returns the square root of a number.
326
326
///
327
- /// Returns NaN if `self` is a negative number.
327
+ /// Returns NaN if `self` is a negative number other than `-0.0` .
328
328
///
329
329
/// # Examples
330
330
///
331
331
/// ```
332
332
/// let positive = 4.0_f32;
333
333
/// let negative = -4.0_f32;
334
+ /// let negative_zero = -0.0_f32;
334
335
///
335
336
/// let abs_difference = (positive.sqrt() - 2.0).abs();
336
337
///
337
338
/// assert!(abs_difference <= f32::EPSILON);
338
339
/// assert!(negative.sqrt().is_nan());
340
+ /// assert!(negative_zero.sqrt() == negative_zero);
339
341
/// ```
340
342
#[ must_use = "method returns a new number and does not mutate the original value" ]
341
343
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
Original file line number Diff line number Diff line change @@ -324,18 +324,20 @@ impl f64 {
324
324
325
325
/// Returns the square root of a number.
326
326
///
327
- /// Returns NaN if `self` is a negative number.
327
+ /// Returns NaN if `self` is a negative number other than `-0.0` .
328
328
///
329
329
/// # Examples
330
330
///
331
331
/// ```
332
332
/// let positive = 4.0_f64;
333
333
/// let negative = -4.0_f64;
334
+ /// let negative_zero = -0.0_f64;
334
335
///
335
336
/// let abs_difference = (positive.sqrt() - 2.0).abs();
336
337
///
337
338
/// assert!(abs_difference < 1e-10);
338
339
/// assert!(negative.sqrt().is_nan());
340
+ /// assert!(negative_zero.sqrt() == negative_zero);
339
341
/// ```
340
342
#[ must_use = "method returns a new number and does not mutate the original value" ]
341
343
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
You can’t perform that action at this time.
0 commit comments