Skip to content

Commit cd868dc

Browse files
committed
Cover edge cases for {f32, f64}.hypot() docs
Re-phrase in a way that handles input values being either 0 or negative.
1 parent e4dae0d commit cd868dc

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

library/std/src/f32.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,10 @@ impl f32 {
581581
unsafe { cmath::cbrtf(self) }
582582
}
583583

584-
/// Calculates the length of the hypotenuse of a right-angle triangle given
585-
/// legs of length `x` and `y`.
584+
/// Compute the distance between the origin and a point (`x`, `y`) on the
585+
/// Euclidean plane. Equivalently, compute the length of the hypotenuse of a
586+
/// right-angle triangle with other sides having length `x.abs()` and
587+
/// `y.abs()`.
586588
///
587589
/// # Examples
588590
///

library/std/src/f64.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,10 @@ impl f64 {
583583
unsafe { cmath::cbrt(self) }
584584
}
585585

586-
/// Calculates the length of the hypotenuse of a right-angle triangle given
587-
/// legs of length `x` and `y`.
586+
/// Compute the distance between the origin and a point (`x`, `y`) on the
587+
/// Euclidean plane. Equivalently, compute the length of the hypotenuse of a
588+
/// right-angle triangle with other sides having length `x.abs()` and
589+
/// `y.abs()`.
588590
///
589591
/// # Examples
590592
///

0 commit comments

Comments
 (0)