From 2a9fbd218224a2dc578ca062090fb7fef0f8b2da Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Fri, 24 Jan 2025 18:07:18 +0100 Subject: [PATCH 1/3] Document powf and powi values that are always 1.0 (f32) f32 part for bug #90429 --- library/std/src/f32.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs index 438d77b1626be..961906426c68d 100644 --- a/library/std/src/f32.rs +++ b/library/std/src/f32.rs @@ -306,8 +306,9 @@ impl f32 { /// ``` /// let x = 2.0_f32; /// let abs_difference = (x.powi(2) - (x * x)).abs(); - /// /// assert!(abs_difference <= f32::EPSILON); + /// + /// assert_eq!(f64::powi(f32::NAN, 0), 1.0); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] @@ -329,8 +330,10 @@ impl f32 { /// ``` /// let x = 2.0_f32; /// let abs_difference = (x.powf(2.0) - (x * x)).abs(); - /// /// assert!(abs_difference <= f32::EPSILON); + /// + /// assert_eq!(f32::powf(1.0, f32::NAN), 1.0) + /// assert_eq!(f32::powf(f32::NAN, 0.0), 1.0) /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] From 56bb93397c7bbbff4d5ced6dcb9fc540fca2c652 Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Fri, 24 Jan 2025 18:19:22 +0100 Subject: [PATCH 2/3] fix typo of f64 to f32 Co-authored-by: matthewjasper <20113453+matthewjasper@users.noreply.github.com> --- library/std/src/f32.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs index 961906426c68d..4a60a34bba791 100644 --- a/library/std/src/f32.rs +++ b/library/std/src/f32.rs @@ -308,7 +308,7 @@ impl f32 { /// let abs_difference = (x.powi(2) - (x * x)).abs(); /// assert!(abs_difference <= f32::EPSILON); /// - /// assert_eq!(f64::powi(f32::NAN, 0), 1.0); + /// assert_eq!(f32::powi(f32::NAN, 0), 1.0); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] From d39ee71e0fcc8b9d9d7cdf4a579a3981b9b6b978 Mon Sep 17 00:00:00 2001 From: Marijn Schouten Date: Fri, 24 Jan 2025 18:33:20 +0100 Subject: [PATCH 3/3] add semicolons --- library/std/src/f32.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs index 4a60a34bba791..f9b6723788ae3 100644 --- a/library/std/src/f32.rs +++ b/library/std/src/f32.rs @@ -332,8 +332,8 @@ impl f32 { /// let abs_difference = (x.powf(2.0) - (x * x)).abs(); /// assert!(abs_difference <= f32::EPSILON); /// - /// assert_eq!(f32::powf(1.0, f32::NAN), 1.0) - /// assert_eq!(f32::powf(f32::NAN, 0.0), 1.0) + /// assert_eq!(f32::powf(1.0, f32::NAN), 1.0); + /// assert_eq!(f32::powf(f32::NAN, 0.0), 1.0); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"]