Open

Description
Feature gate: #![feature(more_float_constants)]
This is a tracking issue for additional constants in the {f32,f64}::consts
modules.
Public API
// in core::{f32, f64}::consts
/// The golden ratio (φ)
pub const PHI: f64 = 1.618033988749894848204586834365638118_f64;
/// The Euler-Mascheroni constant (γ)
pub const EGAMMA: f64 = 0.577215664901532860606512090082402431_f64;
/// 1/sqrt(π)
pub const FRAC_1_SQRT_PI: f64 = 0.564189583547756286948079451560772586_f64;
/// sqrt(3)
pub const SQRT_3: f64 = 1.732050807568877293527446341505872367_f64;
/// 1/sqrt(3)
pub const FRAC_1_SQRT_3: f64 = 0.577350269189625764509148780501957456_f64;
Steps / History
Unresolved Questions
- Naming of the Euler-Mascheroni constant (gamma)
- Any additional constants?
- ln(3)
Footnotes
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
leonardo-m commentedon Nov 2, 2022
On constants defined like:
Clippy raises a "float has excessive precision" using this lint:
https://rust-lang.github.io/rust-clippy/master/index.html#excessive_precision
torvalamo commentedon May 25, 2023
As for the question of additional constants: SQRT_5, which is an element in the proposed PHI and also used for various geometric and trigonometric calculations. PHI probably covers the most common usage of SQRT_5, but it wouldn't hurt to include it as it is relatively common (more so than EGAMMA I would argue). Just my 2 cents.
temp solution until constants are part of std: rust-lang/rust#103883
Adding more math constants (and a small correction to the description…
Auto merge of rust-lang#103836 - H4x5:extra-float-constants, r=thomcc
FRAC_1_SQRT_2PI
constant rust-lang/libs-team#383Snowiiii commentedon Jan 10, 2025
When this is getting added ?
krsnik02 commentedon Jan 27, 2025
FRAC_1_SQRT_2PI should probably be named FRAC_1_SQRT_TAU since the already existing constant for 2pi is named TAU.
2 remaining items