-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ACP: Add a constant for the golden ratio (phi) to the floating point types #119
Comments
Maybe we should go ahead and add all that we're missing? |
My statement about a "subset" of C++ was incorrect, as can be seen from the comparison table below. Of the total 24 constants, Rust has 19 and C++ has 13. It may be worth adding the 5 constants that are in C++ but not in Rust (phi, gamma, 1/sqrt(pi), sqrt(3), and 1/sqrt(3)). |
We reviewed this in today's @rust-lang/libs-api meeting, and we're fine with adding all five of the additional constants C++ has in that table (the five added by rust-lang/rust#103883). |
Add additional float constants Initial implementation of this ACP: rust-lang/libs-team#119. [Accepted] Tracking issue: rust-lang#103883 The values for the constants are copied from the [`libstdc++` source code](https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/libstdc%2B%2B-v3/include/std/numbers#L57-L120).
Add additional float constants Initial implementation of this ACP: rust-lang/libs-team#119. [Accepted] Tracking issue: #103883 The values for the constants are copied from the [`libstdc++` source code](https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/libstdc%2B%2B-v3/include/std/numbers#L57-L120).
Add additional float constants Initial implementation of this ACP: rust-lang/libs-team#119. [Accepted] Tracking issue: #103883 The values for the constants are copied from the [`libstdc++` source code](https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/libstdc%2B%2B-v3/include/std/numbers#L57-L120).
Add additional float constants Initial implementation of this ACP: rust-lang/libs-team#119. [Accepted] Tracking issue: #103883 The values for the constants are copied from the [`libstdc++` source code](https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/libstdc%2B%2B-v3/include/std/numbers#L57-L120).
Proposal
Problem statement
The
std::f64::consts
module (and its friendstd::f32::consts
) currently contain constants for e (euler's number) and pi, along with some others (ln(2), 1/sqrt(2), etc). These are a subset of the ones in C++, although C++ also includes phi (φ), the golden ratio.I am proposing to add a
PHI
constant to the standard library, in similar fashion to the existing floating point constants.Motivation, use-cases
From a math expression parsing library I'm working on:
Solution sketches
In
core/src/num/f64.rs
:In
core/src/num/f32.rs
:Links and related work
TAU
constant (with some mentions of phi)<numbers>
headerinline constexpr double phi
What happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.
The text was updated successfully, but these errors were encountered: