From 18f43f276f0b6af9c60072e7bf7a2a27cf6dfa76 Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Fri, 24 Jan 2025 18:21:25 +0100 Subject: [PATCH 1/4] Document powf and powi values that are always 1.0 (f16) f16 part for bug #90429 --- library/std/src/f16.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/library/std/src/f16.rs b/library/std/src/f16.rs index 42cd6e3fe2a5f..897666678f8ce 100644 --- a/library/std/src/f16.rs +++ b/library/std/src/f16.rs @@ -324,6 +324,15 @@ impl f16 { /// /// The precision of this function is non-deterministic. This means it varies by platform, /// Rust version, and can even differ within the same execution from one invocation to the next. + /// # Examples + /// + /// ``` + /// let x = 2.0_f16; + /// let abs_difference = (x.powi(2) - (x * x)).abs(); + /// assert!(abs_difference < f16::EPSILON); + /// + /// assert_eq!(f16::powi(f16::NAN, 0), 1.0); + /// ``` #[inline] #[rustc_allow_incoherent_impl] #[unstable(feature = "f16", issue = "116909")] @@ -347,8 +356,10 @@ impl f16 { /// /// let x = 2.0_f16; /// let abs_difference = (x.powf(2.0) - (x * x)).abs(); - /// /// assert!(abs_difference <= f16::EPSILON); + /// + /// assert_eq!(f16::powf(1.0, f16::NAN), 1.0) + /// assert_eq!(f16::powf(f16::NAN, 0.0), 1.0) /// # } /// ``` #[inline] From 145817535e81e393724f9f71bd68db2cb5117139 Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Fri, 24 Jan 2025 18:27:16 +0100 Subject: [PATCH 2/4] add missing spacing --- library/std/src/f16.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/std/src/f16.rs b/library/std/src/f16.rs index 897666678f8ce..5861d20ce4f0f 100644 --- a/library/std/src/f16.rs +++ b/library/std/src/f16.rs @@ -324,6 +324,7 @@ impl f16 { /// /// The precision of this function is non-deterministic. This means it varies by platform, /// Rust version, and can even differ within the same execution from one invocation to the next. + /// /// # Examples /// /// ``` From 965c080edaac993df32ebd5944eb5613d1be6cd6 Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Fri, 24 Jan 2025 18:34:02 +0100 Subject: [PATCH 3/4] add semicolons --- library/std/src/f16.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/f16.rs b/library/std/src/f16.rs index 5861d20ce4f0f..64824b7c8b45f 100644 --- a/library/std/src/f16.rs +++ b/library/std/src/f16.rs @@ -359,8 +359,8 @@ impl f16 { /// let abs_difference = (x.powf(2.0) - (x * x)).abs(); /// assert!(abs_difference <= f16::EPSILON); /// - /// assert_eq!(f16::powf(1.0, f16::NAN), 1.0) - /// assert_eq!(f16::powf(f16::NAN, 0.0), 1.0) + /// assert_eq!(f16::powf(1.0, f16::NAN), 1.0); + /// assert_eq!(f16::powf(f16::NAN, 0.0), 1.0); /// # } /// ``` #[inline] From 4e0d65916a1271a90356d08bf079894edb5cf786 Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Fri, 24 Jan 2025 19:49:31 +0100 Subject: [PATCH 4/4] add /// #![feature(f16)] --- library/std/src/f16.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/src/f16.rs b/library/std/src/f16.rs index 64824b7c8b45f..d194a38664fc3 100644 --- a/library/std/src/f16.rs +++ b/library/std/src/f16.rs @@ -328,6 +328,8 @@ impl f16 { /// # Examples /// /// ``` + /// #![feature(f16)] + /// /// let x = 2.0_f16; /// let abs_difference = (x.powi(2) - (x * x)).abs(); /// assert!(abs_difference < f16::EPSILON);