From 342b449e69253c88da90c56a7da95a3db688208a Mon Sep 17 00:00:00 2001 From: Joshua Rayton Date: Tue, 23 Sep 2025 15:31:58 +0100 Subject: [PATCH] more float constants: sqrt(5), 1/sqrt(5), ln(3) rename EGAMMA to GAMMA --- library/core/src/num/f128.rs | 18 +++++++++++++++++- library/core/src/num/f16.rs | 17 ++++++++++++++++- library/core/src/num/f32.rs | 14 +++++++++++++- library/core/src/num/f64.rs | 14 +++++++++++++- 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index 4fe4735e304c9..b5322b64c1094 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -39,7 +39,7 @@ pub mod consts { /// The Euler-Mascheroni constant (γ) #[unstable(feature = "f128", issue = "116909")] // Also, #[unstable(feature = "more_float_constants", issue = "146939")] - pub const EGAMMA: f128 = 0.577215664901532860606512090082402431042159335939923598805767_f128; + pub const GAMMA: f128 = 0.577215664901532860606512090082402431042159335939923598805767_f128; /// π/2 #[unstable(feature = "f128", issue = "116909")] @@ -107,6 +107,17 @@ pub mod consts { pub const FRAC_1_SQRT_3: f128 = 0.577350269189625764509148780501957455647601751270126876018602_f128; + /// sqrt(5) + #[unstable(feature = "f128", issue = "116909")] + // Also, #[unstable(feature = "more_float_constants", issue = "146939")] + pub const SQRT_5: f128 = 2.23606797749978969640917366873127623544061835961152572427089_f128; + + /// 1/sqrt(5) + #[unstable(feature = "f128", issue = "116909")] + // Also, #[unstable(feature = "more_float_constants", issue = "146939")] + pub const FRAC_1_SQRT_5: f128 = + 0.447213595499957939281834733746255247088123671922305144854179_f128; + /// Euler's number (e) #[unstable(feature = "f128", issue = "116909")] pub const E: f128 = 2.71828182845904523536028747135266249775724709369995957496697_f128; @@ -131,6 +142,11 @@ pub mod consts { #[unstable(feature = "f128", issue = "116909")] pub const LN_2: f128 = 0.693147180559945309417232121458176568075500134360255254120680_f128; + /// ln(3) + #[unstable(feature = "f128", issue = "116909")] + // Also, #[unstable(feature = "more_float_constants", issue = "146939")] + pub const LN_3: f128 = 1.09861228866810969139524523692252570464749055782274945173469_f128; + /// ln(10) #[unstable(feature = "f128", issue = "116909")] pub const LN_10: f128 = 2.30258509299404568401799145468436420760110148862877297603333_f128; diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index 0bea6bc8801d8..8a72233bd3a6e 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -41,7 +41,7 @@ pub mod consts { /// The Euler-Mascheroni constant (γ) #[unstable(feature = "f16", issue = "116909")] // Also, #[unstable(feature = "more_float_constants", issue = "146939")] - pub const EGAMMA: f16 = 0.577215664901532860606512090082402431_f16; + pub const GAMMA: f16 = 0.577215664901532860606512090082402431_f16; /// π/2 #[unstable(feature = "f16", issue = "116909")] @@ -104,6 +104,16 @@ pub mod consts { // Also, #[unstable(feature = "more_float_constants", issue = "146939")] pub const FRAC_1_SQRT_3: f16 = 0.577350269189625764509148780501957456_f16; + /// sqrt(5) + #[unstable(feature = "f16", issue = "116909")] + // Also, #[unstable(feature = "more_float_constants", issue = "146939")] + pub const SQRT_5: f16 = 2.236067977499789696409173668731276235_f16; + + /// 1/sqrt(5) + #[unstable(feature = "f16", issue = "116909")] + // Also, #[unstable(feature = "more_float_constants", issue = "146939")] + pub const FRAC_1_SQRT_5: f16 = 0.447213595499957939281834733746255247_f16; + /// Euler's number (e) #[unstable(feature = "f16", issue = "116909")] pub const E: f16 = 2.71828182845904523536028747135266250_f16; @@ -128,6 +138,11 @@ pub mod consts { #[unstable(feature = "f16", issue = "116909")] pub const LN_2: f16 = 0.693147180559945309417232121458176568_f16; + /// ln(3) + #[unstable(feature = "f16", issue = "116909")] + // Also, #[unstable(feature = "more_float_constants", issue = "146939")] + pub const LN_3: f16 = 1.098612288668109691395245236922525704_f16; + /// ln(10) #[unstable(feature = "f16", issue = "116909")] pub const LN_10: f16 = 2.30258509299404568401799145468436421_f16; diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index e380cc698f574..7d058574a164e 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -296,7 +296,7 @@ pub mod consts { /// The Euler-Mascheroni constant (γ) #[unstable(feature = "more_float_constants", issue = "146939")] - pub const EGAMMA: f32 = 0.577215664901532860606512090082402431_f32; + pub const GAMMA: f32 = 0.577215664901532860606512090082402431_f32; /// π/2 #[stable(feature = "rust1", since = "1.0.0")] @@ -355,6 +355,14 @@ pub mod consts { #[unstable(feature = "more_float_constants", issue = "146939")] pub const FRAC_1_SQRT_3: f32 = 0.577350269189625764509148780501957456_f32; + /// sqrt(5) + #[unstable(feature = "more_float_constants", issue = "146939")] + pub const SQRT_5: f32 = 2.236067977499789696409173668731276235_f32; + + /// 1/sqrt(5) + #[unstable(feature = "more_float_constants", issue = "146939")] + pub const FRAC_1_SQRT_5: f32 = 0.447213595499957939281834733746255247_f32; + /// Euler's number (e) #[stable(feature = "rust1", since = "1.0.0")] pub const E: f32 = 2.71828182845904523536028747135266250_f32; @@ -379,6 +387,10 @@ pub mod consts { #[stable(feature = "rust1", since = "1.0.0")] pub const LN_2: f32 = 0.693147180559945309417232121458176568_f32; + /// ln(3) + #[unstable(feature = "more_float_constants", issue = "146939")] + pub const LN_3: f32 = 1.098612288668109691395245236922525704_f32; + /// ln(10) #[stable(feature = "rust1", since = "1.0.0")] pub const LN_10: f32 = 2.30258509299404568401799145468436421_f32; diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index ff7449fd996ce..3ec1e45272cdb 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -296,7 +296,7 @@ pub mod consts { /// The Euler-Mascheroni constant (γ) #[unstable(feature = "more_float_constants", issue = "146939")] - pub const EGAMMA: f64 = 0.577215664901532860606512090082402431_f64; + pub const GAMMA: f64 = 0.577215664901532860606512090082402431_f64; /// π/2 #[stable(feature = "rust1", since = "1.0.0")] @@ -355,6 +355,14 @@ pub mod consts { #[unstable(feature = "more_float_constants", issue = "146939")] pub const FRAC_1_SQRT_3: f64 = 0.577350269189625764509148780501957456_f64; + /// sqrt(5) + #[unstable(feature = "more_float_constants", issue = "146939")] + pub const SQRT_5: f64 = 2.236067977499789696409173668731276235_f64; + + /// 1/sqrt(5) + #[unstable(feature = "more_float_constants", issue = "146939")] + pub const FRAC_1_SQRT_5: f64 = 0.447213595499957939281834733746255247_f64; + /// Euler's number (e) #[stable(feature = "rust1", since = "1.0.0")] pub const E: f64 = 2.71828182845904523536028747135266250_f64; @@ -379,6 +387,10 @@ pub mod consts { #[stable(feature = "rust1", since = "1.0.0")] pub const LN_2: f64 = 0.693147180559945309417232121458176568_f64; + /// ln(3) + #[unstable(feature = "more_float_constants", issue = "146939")] + pub const LN_3: f64 = 1.098612288668109691395245236922525704_f64; + /// ln(10) #[stable(feature = "rust1", since = "1.0.0")] pub const LN_10: f64 = 2.30258509299404568401799145468436421_f64;