-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: add constants/float64/inv-two-pi
#8982
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
base: develop
Are you sure you want to change the base?
feat: add constants/float64/inv-two-pi
#8982
Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
Hi @Neerajpathak07! |
| * @default 0.15915494309189535 | ||
| * @see [Wikipedia]{@link https://en.wikipedia.org/wiki/Pi} | ||
| */ | ||
| var FLOAT64_INV_TWO_PI = 0.15915494309189533576888376337251436203445964574045644874766734405889679763422653509534861042142103174415371554; // eslint-disable-line max-len |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the value exceeding the precision limit. The return value should be the same as the set default value.
| * @default 0.15915494309189535 | ||
| * @see [Wikipedia]{@link https://en.wikipedia.org/wiki/Pi} | ||
| */ | ||
| var FLOAT64_INV_TWO_PI = 0.15915494309189533576888376337251436203445964574045644874766734405889679763422653509534861042142103174415371554; // eslint-disable-line max-len |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| var FLOAT64_INV_TWO_PI = 0.15915494309189533576888376337251436203445964574045644874766734405889679763422653509534861042142103174415371554; // eslint-disable-line max-len | |
| var FLOAT64_INV_TWO_PI = 0.15915494309189535; |
| /** | ||
| * Macro for the inverse of 2π (1/(2π)). | ||
| */ | ||
| #define STDLIB_CONSTANT_FLOAT64_INV_TWO_PI 0.15915494309189533577 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the C header file giving out different return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm interested in knowing where this value is coming from did you take any reference you would like to share?
|
Thanks for the review @Neerajpathak07! Regarding the long value: It is actually the arbitrary-precision decimal expansion of 1 / (2π). It wasn't calculated using the standard Math.PI, but generated using a high-precision tool (mpmath) to ensure the literal is the exact mathematical "source of truth". The value in the C header (...3577) appears to be the same value but rounded to 20 decimal places (since the next digit in the expansion is 8, it rounded up ...76 to ...77). However, I agree with you for practical float64 representation in JS, the truncated version avoids confusion. I have updated the value to match the standard 15-17 digit precision as suggested. |
| </section> | ||
|
|
||
| <!-- /.related --> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you have added an C header file you'll have to add the documentation for C usage as well. To address the macro version.
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:
Resolves none
Description
This pull request:
constants/float64/inv-two-piRelated Issues
This pull request has the following related issues:
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
@stdlib-js/reviewers