about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-04-14 07:58:42 +0200
committerGitHub <noreply@github.com>2023-04-14 07:58:42 +0200
commita7889d1730d48fa987c513f97250f3a3570a919e (patch)
tree4827fed38ec9e766b80c42a54e3c3d2f4986cc36
parent35bd52e888489c605e5f5ce35fea17a1743adf91 (diff)
parentcd868dcf987b71148bc40271aede9f5b02645c26 (diff)
downloadrust-a7889d1730d48fa987c513f97250f3a3570a919e.tar.gz
rust-a7889d1730d48fa987c513f97250f3a3570a919e.zip
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.
-rw-r--r--library/std/src/f32.rs6
-rw-r--r--library/std/src/f64.rs6
2 files changed, 8 insertions, 4 deletions
diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs
index c7c33678fd3..408244b2ce9 100644
--- a/library/std/src/f32.rs
+++ b/library/std/src/f32.rs
@@ -581,8 +581,10 @@ impl f32 {
         unsafe { cmath::cbrtf(self) }
     }
 
-    /// Calculates the length of the hypotenuse of a right-angle triangle given
-    /// legs of length `x` and `y`.
+    /// Compute the distance between the origin and a point (`x`, `y`) on the
+    /// Euclidean plane. Equivalently, compute the length of the hypotenuse of a
+    /// right-angle triangle with other sides having length `x.abs()` and
+    /// `y.abs()`.
     ///
     /// # Examples
     ///
diff --git a/library/std/src/f64.rs b/library/std/src/f64.rs
index b1faa670307..6782b861f11 100644
--- a/library/std/src/f64.rs
+++ b/library/std/src/f64.rs
@@ -583,8 +583,10 @@ impl f64 {
         unsafe { cmath::cbrt(self) }
     }
 
-    /// Calculates the length of the hypotenuse of a right-angle triangle given
-    /// legs of length `x` and `y`.
+    /// Compute the distance between the origin and a point (`x`, `y`) on the
+    /// Euclidean plane. Equivalently, compute the length of the hypotenuse of a
+    /// right-angle triangle with other sides having length `x.abs()` and
+    /// `y.abs()`.
     ///
     /// # Examples
     ///