-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
Add FRAC_1_SQRT_2PI
constant to f16/f32/f64/f128
#125253
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
This comment has been minimized.
This comment has been minimized.
48e845f
to
6cfb6b6
Compare
Thanks, added it at rust-lang/libs-team#383. Exciting! @rustbot review |
6cfb6b6
to
eb72938
Compare
This is create symmetry between the already existing TAU constant (2pi) and the newly-introduced FRAC_1_SQRT_2PI, keeping the more common name while increasing visibility.
I added |
This adds the
FRAC_1_SQRT_2PI
to thef16
,f32
,f64
andf128
as1/√(2π)
. The rationale is that whileFRAC_1_SQRT_PI
already exists, Gaussian calculations for random normal distributions require a1/(σ√(2π))
term, which could then be directly expressed e.g. asf32::FRAC_1_SQRT_2PI / sigma
.The actual value is approximately
1/√(2π) = 0.3989422804014326779399460599343818684758586311649346576659258296…
. Truncated/rounded forms were used for the individual types.I did not any of the#[unstable]
attributes since I am not aware of their implications.Edit: I applied the stability attributes from the surrounding types according to what seemed most likely correct. I believe the
more_float_constants
feature marker is incorrectly applied, but I wasn't sure how to proceed.