You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#119 ($\phi, \gamma, \frac1{\sqrt\pi}, \sqrt3, \frac1{\sqrt3}$) was accepted because they are part of C++20's list of constants
#383 ($\frac1{\sqrt{2\pi}}$) was accepted because it indeed appears in many formula e.g. the normal distribution, error function, Fourier transform, Black-Scholes model etc.
What is the reason we want $\sqrt5, \frac1{\sqrt5}, \ln 3$ in the standard library? IMO calculating Fibonacci number using $F_n = \left\lfloor \frac{\phi^n}{\sqrt5} \right\rceil$ is not one ($F_{2n} = F_n(2F_{n-1}+F_n)$ is perhaps more efficient), and this does not explain $\sqrt5, \ln 3$ either.
What is the reason we want $\sqrt{5}$ , $\frac{1}{\sqrt{5}}$, $\ln 3$ in the standard library? IMO calculating Fibonacci number using $F_n = ⌊ \frac{\phi^n}{\sqrt{5}} ⌉$ is not one ( $F_{2n} = F_n(2F_{n-1} + F_n)$ ) is perhaps more efficient), and this does not explain $\sqrt{5}$ , $\ln 3$ either.
I agree with this, it is useful in geometry and trigonometry. When working with the golden ratio, the sqrt(5) is often useful by itself too. It's also used with Diophantine approximations. At least 8 others seemed to agree with this comment.
$\frac{1}{\sqrt{5}}$ was proposed by me in the pull request. This is so division by the sqrt(5) can be done by reciprocal multiplication at full floating point precision.
$\ln 3$ was originally proposed in the original issue (rust-lang/rust#103883) for additional constants.
I no longer think it's needed. Searching GitHub for rust projects that contain the beginning of the decimal expansion didn't give results. It's not even a constant on Wikipedia's list of mathematical constants and it doesn't have it's own Wikipedia page unlike sqrt(5).
Could you clarify which part you think is no longer needed? Just ln3 or the whole proposal?
Additionally see rust-lang/rust#146939 (comment), we'd like to see some experimentation with constant-time infinite-precision calculation to happen to see whether a more general approach to produce such values is possible.
Could you clarify which part you think is no longer needed? Just ln3 or the whole proposal?
Additionally see rust-lang/rust#146939 (comment), we'd like to see some experimentation with constant-time infinite-precision calculation to happen to see whether a more general approach to produce such values is possible.
I meant that I think that just $\ln 3$ is not needed. This other implementation looks interesting too.
We discussed this during today's libs-API meeting. We're a bit hesitant to add these since it feels pretty close to the line of diminishing returns, but this one barely passes.
I meant that I think that just ln 3 is not needed. This other implementation looks interesting too.
Ok, just FRAC_1_SQRT_5 and SQRT_5 then.
Please file a new tracking issue and then close this one.
Activity
kennytm commentedon Sep 26, 2025
#119 ($\phi, \gamma, \frac1{\sqrt\pi}, \sqrt3, \frac1{\sqrt3}$ ) was accepted because they are part of C++20's list of constants
#383 ($\frac1{\sqrt{2\pi}}$ ) was accepted because it indeed appears in many formula e.g. the normal distribution, error function, Fourier transform, Black-Scholes model etc.
What is the reason we want$\sqrt5, \frac1{\sqrt5}, \ln 3$ in the standard library? IMO calculating Fibonacci number using $F_n = \left\lfloor \frac{\phi^n}{\sqrt5} \right\rceil$ is not one ($F_{2n} = F_n(2F_{n-1}+F_n)$ is perhaps more efficient), and this does not explain $\sqrt5, \ln 3$ either.
joshuarayton commentedon Sep 26, 2025
I agree with this, it is useful in geometry and trigonometry. When working with the golden ratio, the sqrt(5) is often useful by itself too. It's also used with Diophantine approximations. At least 8 others seemed to agree with this comment.
I no longer think it's needed. Searching GitHub for rust projects that contain the beginning of the decimal expansion didn't give results. It's not even a constant on Wikipedia's list of mathematical constants and it doesn't have it's own Wikipedia page unlike sqrt(5).
the8472 commentedon Sep 30, 2025
Could you clarify which part you think is no longer needed? Just ln3 or the whole proposal?
Additionally see rust-lang/rust#146939 (comment), we'd like to see some experimentation with constant-time infinite-precision calculation to happen to see whether a more general approach to produce such values is possible.
joshuarayton commentedon Oct 4, 2025
I meant that I think that just$\ln 3$ is not needed. This other implementation looks interesting too.
the8472 commentedon Oct 28, 2025
We discussed this during today's libs-API meeting. We're a bit hesitant to add these since it feels pretty close to the line of diminishing returns, but this one barely passes.
Ok, just
FRAC_1_SQRT_5andSQRT_5then.Please file a new tracking issue and then close this one.
Rollup merge of rust-lang#151825 - joshuarayton:more-float-constants,…
Rollup merge of rust-lang#151825 - joshuarayton:more-float-constants,…
Rollup merge of rust-lang#151825 - joshuarayton:more-float-constants,…
Rollup merge of rust-lang#151825 - joshuarayton:more-float-constants,…
Rollup merge of rust-lang#151825 - joshuarayton:more-float-constants,…
Unrolled build for #151825
clarfonthey commentedon Aug 30, 2026
Tracked in rust-lang/rust#146939.