Skip to content

Tracking Issue for more_float_constants #103883

Open
@ghost

Description

Feature gate: #![feature(more_float_constants)]

This is a tracking issue for additional constants in the {f32,f64}::consts modules.

ACP: rust-lang/libs-team#119

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

  • Final comment period (FCP)1
    Stabilization PR

Unresolved Questions

  • Naming of the Euler-Mascheroni constant (gamma)
  • Any additional constants?
    • ln(3)

Footnotes

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

Activity

ghost added
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
on Nov 2, 2022
ghost added
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
on Nov 2, 2022
leonardo-m

leonardo-m commented on Nov 2, 2022

@leonardo-m

On constants defined like:

pub const PHI: f64 = 1.618033988749894848204586834365638118_f64;

Clippy raises a "float has excessive precision" using this lint:

https://rust-lang.github.io/rust-clippy/master/index.html#excessive_precision

ghost
torvalamo

torvalamo commented on May 25, 2023

@torvalamo

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.

added a commit that references this issue on Aug 28, 2023

Auto merge of rust-lang#103836 - H4x5:extra-float-constants, r=thomcc

Snowiiii

Snowiiii commented on Jan 10, 2025

@Snowiiii

When this is getting added ?

krsnik02

krsnik02 commented on Jan 27, 2025

@krsnik02

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

Loading
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

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @torvalamo@krsnik02@tgross35@leonardo-m@AregevDev

        Issue actions

          Tracking Issue for `more_float_constants` · Issue #103883 · rust-lang/rust