rust-lang / rust-lang/rust

Tracking Issue (take 2) for `more_float_constants`

Open
#146,939 18 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-floating-point C-tracking-issue disposition-merge finished-final-comment-period T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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 https://github.com/rust-lang/rust/issues/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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the core::{f16, f32, f64, f128}::consts API and the linked implementation and constant-addition pull requests. Review the unresolved questions about naming, additional constants, and the cutoff, then follow the stabilization process; done requires completing the final comment period and stabilization PR.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.