Skip to content

Commit a7889d1

Browse files
authored
Rollup merge of #110298 - jmaargh:jmaargh/hypot-docs-edge-cases, r=thomcc
Cover edge cases for {f32, f64}.hypot() docs Fixes #88944 The Euclidean distance is a more general way to express what these functions do, and covers the edge cases of zero and negative inputs. Does not cover the case of non-normal input values (as the [POSIX docs](https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/) do), but the docs for the rest of the functions in these modules do not address this, I assumed it was not desired.
2 parents 35bd52e + cd868dc commit a7889d1

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)