From 634564a50696340d8136855e7559cb79f99f4eaf Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Fri, 24 Jan 2025 18:25:39 +0100 Subject: [PATCH 1/3] Document powf and powi values that are always 1.0 (f128) f128 part for bug #90429 --- library/std/src/f128.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/library/std/src/f128.rs b/library/std/src/f128.rs index 4f37e18a8cd76..a2531ac25fdac 100644 --- a/library/std/src/f128.rs +++ b/library/std/src/f128.rs @@ -324,6 +324,16 @@ impl f128 { /// /// 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_f128; + /// let abs_difference = (x.powi(2) - (x * x)).abs(); + /// assert!(abs_difference < f128::EPSILON); + /// + /// assert_eq!(f128::powi(f128::NAN, 0), 1.0); + /// ``` #[inline] #[rustc_allow_incoherent_impl] #[unstable(feature = "f128", issue = "116909")] @@ -347,8 +357,10 @@ impl f128 { /// /// let x = 2.0_f128; /// let abs_difference = (x.powf(2.0) - (x * x)).abs(); - /// /// assert!(abs_difference <= f128::EPSILON); + /// + /// assert_eq!(f128::powf(1.0, f128::NAN), 1.0) + /// assert_eq!(f128::powf(f128::NAN, 0.0), 1.0) /// # } /// ``` #[inline] From c30d2c97ee37c810bc8feab95891d19b4c561ac5 Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Fri, 24 Jan 2025 18:34:51 +0100 Subject: [PATCH 2/3] add semicolons --- library/std/src/f128.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/f128.rs b/library/std/src/f128.rs index a2531ac25fdac..a3107725fa45e 100644 --- a/library/std/src/f128.rs +++ b/library/std/src/f128.rs @@ -359,8 +359,8 @@ impl f128 { /// let abs_difference = (x.powf(2.0) - (x * x)).abs(); /// assert!(abs_difference <= f128::EPSILON); /// - /// assert_eq!(f128::powf(1.0, f128::NAN), 1.0) - /// assert_eq!(f128::powf(f128::NAN, 0.0), 1.0) + /// assert_eq!(f128::powf(1.0, f128::NAN), 1.0); + /// assert_eq!(f128::powf(f128::NAN, 0.0), 1.0); /// # } /// ``` #[inline] From 6a2edd93826201edd458ac77534a21b34f4f3b46 Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Fri, 24 Jan 2025 19:51:39 +0100 Subject: [PATCH 3/3] add /// #![feature(f128)] --- library/std/src/f128.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/src/f128.rs b/library/std/src/f128.rs index a3107725fa45e..623f6f04155a0 100644 --- a/library/std/src/f128.rs +++ b/library/std/src/f128.rs @@ -328,6 +328,8 @@ impl f128 { /// # Examples /// /// ``` + /// #![feature(f128)] + /// /// let x = 2.0_f128; /// let abs_difference = (x.powi(2) - (x * x)).abs(); /// assert!(abs_difference < f128::EPSILON);