feat: add `constants/float16/inv-pi`
type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report:
task: lint_filenames status: passed task: lint_editorconfig status: passed task: lint_markdown status: passed task: lint_package_json status: passed task: lint_repl_help status: passed task: lint_javascript_src status: passed task: lint_javascript_cli status: na task: lint_javascript_examples status: passed task: lint_javascript_tests status: passed task: lint_javascript_benchmarks status: na task: lint_python status: na task: lint_r status: na task: lint_c_src status: na task: lint_c_examples status: na task: lint_c_benchmarks status: na task: lint_c_tests_fixtures status: na task: lint_shell status: na task: lint_typescript_declarations status: passed task: lint_typescript_tests status: passed task: lint_license_headers status: passed ---
Resolves #{{TODO: add issue number}}.
Description
What is the purpose of this pull request?
This pull request:
- add
constants/float16/inv-pi
Related Issues
Does this pull request have any related issues?
This pull request has the following related issues:
- #{{TODO: add related issue number}}
Questions
Any questions for reviewers of this pull request?
No.
Other
Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.
No.
Checklist
Please ensure the following tasks are completed before submitting this pull request.
- [x] Read, understood, and followed the contributing guidelines.
AI Assistance
When authoring the changes proposed in this PR, did you use any kind of AI assistance?
- [ ] Yes
- [x] No
If you answered "yes" above, how did you use AI assistance?
- [ ] Code generation (e.g., when writing an implementation or fixing a bug)
- [ ] Test/benchmark generation
- [ ] Documentation (including examples)
- [ ] Research and understanding
Disclosure
If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".
@stdlib-js/reviewers
Coverage Report
| Package | Statements | Branches | Functions | Lines |
|---|---|---|---|---|
| constants/float16/inv-pi | $\color{green}48/48$ $\color{green}+100.00%$ |
$\color{green}1/1$ $\color{green}+100.00%$ |
$\color{green}0/0$ $\color{green}+100.00%$ |
$\color{green}48/48$ $\color{green}+100.00%$ |
The above coverage report was generated for the changes in this PR.
Hi @Neerajpathak07,
While working on inv-two-pi across all precisions, I also noticed that inv-pi currently exists only in my open PR for float16.
If you think it makes sense, I can add the float32 and float64 versions as well once the float16 PR is merged or get review.
Just wanted to check before proceeding.
It's better to hold those for a while till we can get the PR's on inv-two-pi in.
One thing that's on top of my mind is that whether this package is necessary and if so which packages would we be needing this constant for.
Thanks for the clarification, @Neerajpathak07!
Regarding the usefulness of inv-pi:
1/π appears quite frequently in numerical code, especially in :
- probability distributions (e.g., Cauchy pdf:
1/(π * (1 + x²))), - Fourier/signal-processing normalizations, and
- several special-function kernels where
πor2πfactors appear in denominators.
Having a dedicated constant avoids repeated divisions, ensures consistent rounding across precisions, and keeps the API parallel to existing constants like two-pi, and half-pi.
But yes, I am happy to wait until the inv-two-pi PRs land before proceeding further.