File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -324,18 +324,20 @@ impl f32 {
324324
325325 /// Returns the square root of a number.
326326 ///
327- /// Returns NaN if `self` is a negative number.
327+ /// Returns NaN if `self` is a negative number other than `-0.0` .
328328 ///
329329 /// # Examples
330330 ///
331331 /// ```
332332 /// let positive = 4.0_f32;
333333 /// let negative = -4.0_f32;
334+ /// let negative_zero = -0.0_f32;
334335 ///
335336 /// let abs_difference = (positive.sqrt() - 2.0).abs();
336337 ///
337338 /// assert!(abs_difference <= f32::EPSILON);
338339 /// assert!(negative.sqrt().is_nan());
340+ /// assert!(negative_zero.sqrt() == negative_zero);
339341 /// ```
340342 #[ must_use = "method returns a new number and does not mutate the original value" ]
341343 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
Original file line number Diff line number Diff line change @@ -324,18 +324,20 @@ impl f64 {
324324
325325 /// Returns the square root of a number.
326326 ///
327- /// Returns NaN if `self` is a negative number.
327+ /// Returns NaN if `self` is a negative number other than `-0.0` .
328328 ///
329329 /// # Examples
330330 ///
331331 /// ```
332332 /// let positive = 4.0_f64;
333333 /// let negative = -4.0_f64;
334+ /// let negative_zero = -0.0_f64;
334335 ///
335336 /// let abs_difference = (positive.sqrt() - 2.0).abs();
336337 ///
337338 /// assert!(abs_difference < 1e-10);
338339 /// assert!(negative.sqrt().is_nan());
340+ /// assert!(negative_zero.sqrt() == negative_zero);
339341 /// ```
340342 #[ must_use = "method returns a new number and does not mutate the original value" ]
341343 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
You can’t perform that action at this time.
0 commit comments