From eb729380499b12cb539d665221d5930a06467024 Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Wed, 22 May 2024 11:07:08 +0200 Subject: [PATCH 1/2] Add FRAC_1_SQRT_2PI constant to f16/f32/f64/f128 --- library/core/src/num/f128.rs | 6 ++++++ library/core/src/num/f16.rs | 5 +++++ library/core/src/num/f32.rs | 4 ++++ library/core/src/num/f64.rs | 4 ++++ 4 files changed, 19 insertions(+) diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index 9362dc8765492..75eed26485881 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -68,6 +68,12 @@ pub mod consts { pub const FRAC_1_SQRT_PI: f128 = 0.564189583547756286948079451560772585844050629328998856844086_f128; + /// 1/sqrt(2π) + #[unstable(feature = "f128", issue = "116909")] + // Also, #[unstable(feature = "more_float_constants", issue = "103883")] + pub const FRAC_1_SQRT_2PI: f128 = + 0.398942280401432677939946059934381868475858631164934657665926_f128; + /// 2/π #[unstable(feature = "f128", issue = "116909")] pub const FRAC_2_PI: f128 = 0.636619772367581343075535053490057448137838582961825794990669_f128; diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index c4d4584544bad..955314516a4a7 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -67,6 +67,11 @@ pub mod consts { // Also, #[unstable(feature = "more_float_constants", issue = "103883")] pub const FRAC_1_SQRT_PI: f16 = 0.564189583547756286948079451560772586_f16; + /// 1/sqrt(2π) + #[unstable(feature = "f16", issue = "116909")] + // Also, #[unstable(feature = "more_float_constants", issue = "103883")] + pub const FRAC_1_SQRT_2PI: f16 = 0.398942280401432677939946059934381868_f16; + /// 2/π #[unstable(feature = "f16", issue = "116909")] pub const FRAC_2_PI: f16 = 0.636619772367581343075535053490057448_f16; diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 2e715fb0bdde7..8c591af3c0d0f 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -327,6 +327,10 @@ pub mod consts { #[unstable(feature = "more_float_constants", issue = "103883")] pub const FRAC_1_SQRT_PI: f32 = 0.564189583547756286948079451560772586_f32; + /// 1/sqrt(2π) + #[unstable(feature = "more_float_constants", issue = "103883")] + pub const FRAC_1_SQRT_2PI: f32 = 0.398942280401432677939946059934381868_f32; + /// 2/π #[stable(feature = "rust1", since = "1.0.0")] pub const FRAC_2_PI: f32 = 0.636619772367581343075535053490057448_f32; diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index db8e1f318adba..db458c4375ce7 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -327,6 +327,10 @@ pub mod consts { #[unstable(feature = "more_float_constants", issue = "103883")] pub const FRAC_1_SQRT_PI: f64 = 0.564189583547756286948079451560772586_f64; + /// 1/sqrt(2π) + #[unstable(feature = "more_float_constants", issue = "103883")] + pub const FRAC_1_SQRT_2PI: f64 = 0.398942280401432677939946059934381868_f64; + /// 2/π #[stable(feature = "rust1", since = "1.0.0")] pub const FRAC_2_PI: f64 = 0.636619772367581343075535053490057448_f64; From 54bb08d53881da7c43b91fd5a6bd8ef9a3b754e6 Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Wed, 29 May 2024 14:58:34 +0200 Subject: [PATCH 2/2] Add FRAC_1_SQRT_2PI doc alias to FRAC_1_SQRT_TAU This is create symmetry between the already existing TAU constant (2pi) and the newly-introduced FRAC_1_SQRT_2PI, keeping the more common name while increasing visibility. --- library/core/src/num/f128.rs | 1 + library/core/src/num/f16.rs | 1 + library/core/src/num/f32.rs | 1 + library/core/src/num/f64.rs | 1 + 4 files changed, 4 insertions(+) diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index 75eed26485881..129f62fb43d1a 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -69,6 +69,7 @@ pub mod consts { 0.564189583547756286948079451560772585844050629328998856844086_f128; /// 1/sqrt(2π) + #[doc(alias = "FRAC_1_SQRT_TAU")] #[unstable(feature = "f128", issue = "116909")] // Also, #[unstable(feature = "more_float_constants", issue = "103883")] pub const FRAC_1_SQRT_2PI: f128 = diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index 955314516a4a7..7a488cd6bf6fa 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -68,6 +68,7 @@ pub mod consts { pub const FRAC_1_SQRT_PI: f16 = 0.564189583547756286948079451560772586_f16; /// 1/sqrt(2π) + #[doc(alias = "FRAC_1_SQRT_TAU")] #[unstable(feature = "f16", issue = "116909")] // Also, #[unstable(feature = "more_float_constants", issue = "103883")] pub const FRAC_1_SQRT_2PI: f16 = 0.398942280401432677939946059934381868_f16; diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 8c591af3c0d0f..8e9c7b4d11f32 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -328,6 +328,7 @@ pub mod consts { pub const FRAC_1_SQRT_PI: f32 = 0.564189583547756286948079451560772586_f32; /// 1/sqrt(2π) + #[doc(alias = "FRAC_1_SQRT_TAU")] #[unstable(feature = "more_float_constants", issue = "103883")] pub const FRAC_1_SQRT_2PI: f32 = 0.398942280401432677939946059934381868_f32; diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index db458c4375ce7..5247897437a0c 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -328,6 +328,7 @@ pub mod consts { pub const FRAC_1_SQRT_PI: f64 = 0.564189583547756286948079451560772586_f64; /// 1/sqrt(2π) + #[doc(alias = "FRAC_1_SQRT_TAU")] #[unstable(feature = "more_float_constants", issue = "103883")] pub const FRAC_1_SQRT_2PI: f64 = 0.398942280401432677939946059934381868_f64;