Skip to content

Tracking Issue (take 2) for more_float_constants #146939

Open

Description

@tgross35

Feature gate: #![feature(more_float_constants)]

This is a tracking issue for additional constants in the {f16, f32, f64, f128}::consts modules. Most of these match C++, with the exception of 1/sqrt(2π) https://en.cppreference.com/w/cpp/numeric/constants.html.

The original tracking issue was #103883 but we lost the ability to edit the top post.

Public API

// in core::{f16, f32, f64, f128}::consts

/// 1/sqrt(π)
pub const FRAC_1_SQRT_PI: f64 = 0.564189583547756286948079451560772586_f64;

/// 1/sqrt(2π)
pub const FRAC_1_SQRT_2PI: f64 = 0.398942280401432677939946059934381868_f64;

/// sqrt(3)
pub const SQRT_3: f64 = 1.732050807568877293527446341505872367_f64;

/// 1/sqrt(3)
pub const FRAC_1_SQRT_3: f64 = 0.577350269189625764509148780501957456_f64;

/* Already stabilized as euler_gamma_golden_ratio */

/// The golden ratio (φ)
pub const GOLDEN_RATIO: f64 = 1.618033988749894848204586834365638118_f64;

/// The Euler-Mascheroni constant (γ)
pub const EULER_GAMMA: f64 = 0.577215664901532860606512090082402431_f64;

Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

Unresolved Questions

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩

Activity

  1. added
    T-libs-api[DEPRECATED; DO NOT USE]
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    A-floating-pointArea: Floating point numbers and arithmetic
    on Sep 23, 2025
  2. changed the title [-]Tracking Issue take 2 for `more_float_constants`[/-] [+]Tracking Issue (take 2) for `more_float_constants`[/+] on Sep 23, 2025
  3. tgross35 commented on Sep 26, 2025

    @tgross35
    MemberAuthor

    Since there is a proposal for more constants at rust-lang/libs-team#661, seems worth discussing whether there is interest in stabilizing the ones we already have. They have been unstably around since 2023, and most of the values have been stable for a few thousand years. There are a few unresolved questions on the issue.

    @rustbot label +I-libs-api-nominated

    Names for PHI and EGAMMA have come up a few times. Survey of other languages:

  4. tgross35 commented on Sep 26, 2025

    @tgross35
    MemberAuthor

    @joshuarayton replying from #103883 (comment):

    I also think that EGAMMA should be renamed to GAMMA. Most of the time if the full name is stated, it is either "Euler's constant" or the "Euler-Mascheroni constant". When mentioning it briefly it is just referred to as "gamma". All the other constants named after Greek letters are also only named after their respective Greek letter: pi, tau, phi. So for consistency it should simply be named GAMMA.

    Note that this is a soft conflict with the gamma function (tgamma in math.h) which is represented by an uppercase gamma.

    My personal preference would be to closer match Julia and Numpy by calling these EULER_GAMMA and GOLDEN_RATIO (don't feel very strongly about phi though).

  5. joshuarayton commented on Sep 26, 2025

    @joshuarayton
    Contributor

    Note that this is a soft conflict with the gamma function (tgamma in math.h) which is represented by an uppercase gamma.

    My personal preference would be to closer match Julia and Numpy by calling these EULER_GAMMA and GOLDEN_RATIO (don't feel very strongly about phi though).

    My personal preference would be GAMMA for the Euler-Mascheroni constant and PHI for the golden ratio. When these constants can be used multiple times in a single line of code, it's easier to have shorter names to prevent line wrapping.

    I don't think GAMMA (constant) would conflict with gamma (function) because it is typical to have upper-case constant definitions. But I do accept this could be a reason against.

  6. kennytm commented on Sep 27, 2025

    @kennytm
    Member

    i'm fine with GAMMA/EGAMMA/EULER_GAMMA. but if you need a shorter name you could always rename the import yourself.

    use std::f64::consts::EULER_GAMMA as γ;
  7. Jules-Bertholet commented on Sep 27, 2025

    @Jules-Bertholet
    Contributor

    My personal preference would be to closer match Julia and Numpy by calling these EULER_GAMMA and GOLDEN_RATIO (don't feel very strongly about phi though).

    This seems right to me as well. “Phi” and “gamma” can mean many things, it’s better to use unambiguous names. As @kennytm mentions, you can and should rename the import if needed; that gives the benefit of brevity without losing any clarity.

  8. added a commit that references this issue on Sep 27, 2025
  9. bjoernager commented on Sep 27, 2025

    @bjoernager
    Contributor

    The current convention is to use the name of the symbol rather than of the constant itself (E, PI, and TAU being the stable examples).

    Searching for "gamma constant" on Wikipedia yields both Euler's constant and the Fransén-Robinson constant. Yet, only the former is denoted with a gamma letter (γ vs. F). Some find GAMMA to be too ambiguous for it, but I haven't seen any actual example (yet) of how it is more so than E or TAU – or, more importantly, what it would be confused with in any practical case.

    The Golden Ratio is almost always synonymous with merely "phi." I can't find any other constant that is widely denoted by a phi letter. I would argue that this is similar to how "pi" is exclusive to Archimedes' constant π.

  10. Jules-Bertholet commented on Sep 27, 2025

    @Jules-Bertholet
    Contributor

    PI is by far the most common and well-known name for the constant it references; there wasn’t really any choice there. The proponents of TAU want it to become as common as PI. As for E, personally I think it should have been EULER_E, especially as mathematics generally denotes it with a lowercase “e”, and “E” is used for a different constant.

  11. added a commit that references this issue on Sep 27, 2025
  12. 17 remaining items

  13. kennytm commented on Jan 15, 2026

    @kennytm
    Member

    Yes someone needs to make a PR to rename the two constants EGAMMA, PHI to EULER_GAMMA, GOLDEN_RATIO and stabilize them (only for f32 and f64), as per the FCP decision above.

  14. bjoernager commented on Jan 15, 2026

    @bjoernager
  15. bjoernager commented on Jan 15, 2026

    @bjoernager
    Contributor

    Renaming and stabilisation PR: #151164

  16. added a commit that references this issue on Jan 16, 2026
  17. added a commit that references this issue on Jan 16, 2026
  18. tisonkun commented on Jan 30, 2026

    @tisonkun
    Contributor

    I'd like to see "golden ratio" stabilized. Is there any way to stabilize some of them now?

  19. tgross35 commented on Jan 30, 2026

    @tgross35
    MemberAuthor

    I'd like to see "golden ratio" stabilized. Is there any way to stabilize some of them now?

    🪄 abracadabra!

    Image
  20. added 2 commits that reference this issue on Feb 2, 2026
  21. added 3 commits that reference this issue on Feb 2, 2026
  22. added a commit that references this issue on Feb 3, 2026
  23. added
    T-libsRelevant to the library team, which will review and decide on the PR/issue.
    and removed
    T-libs-api[DEPRECATED; DO NOT USE]
    on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-floating-pointArea: Floating point numbers and arithmeticC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libsRelevant to the library team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions