fix: perform support checks before integer narrowing - #14933
Merged
Conversation
…ists/hypergeometric/cdf` The C implementation cast `x` to `int32_t` before comparing against the distribution support, so finite values outside int32 range invoked undefined conversion behavior and returned 0.0 instead of 1.0 (e.g., `cdf( 1.0e10, 20, 20, 10 )`). Perform the bound comparisons in double space and only narrow once the value is guaranteed in range, matching the JavaScript implementation. Also restores the parameter clause in the function doc comment to match `cdf.h` and `lib/native.js`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E8PkS1AQnkLGgAAEiFeQq7
Contributor
Coverage ReportNo coverage information available. |
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
kgryte
marked this pull request as ready for review
September 4, 2026 05:28
kgryte
previously approved these changes
Sep 4, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E8PkS1AQnkLGgAAEiFeQq7
kgryte
approved these changes
Sep 4, 2026
stats/base/dists/hypergeometric/cdf
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up fixes for commits merged to
developbetween f29c023 (2026-09-03 02:05 +0530) and d656eba (2026-09-03 11:31 +0500).This pull request:
stats/base/dists/hypergeometric/cdf:stats/base/dists/hypergeometric/cdf:f29c023be'smain.ccastxtoint32_tbefore the support-bound checks, so any finitexoutside int32 range hit UB (INT32_MIN on x86-64) andcdf(1.0e10, 20, 20, 10)wrongly returned0.0instead of1.0. Nowlib/node_modules/@stdlib/stats/base/dists/hypergeometric/cdf/src/main.ctruncates into adoubleand compares against(double)lower/(double)upperbefore narrowing, matching the JS reference; verified against a standalone harness for1e10/1e300plus in-support values.src/main.c(f29c023) — it was missing theN/K/n/xparameter clause present incdf.h,lib/native.js,lib/main.js, and the quantile package'ssrc/main.c. Restored it for consistency.Related Issues
No.
Questions
No.
Other
Validation. All 20 commits merged to
developin the last 24 hours were reviewed for bugs, typos, and stdlib style-guide compliance (new code compared against established sibling packages:blas/ext/index-of-not-equalforblas/ext/index-of-falsy;stats/base/dists/hypergeometric/pmf/logpmffor the new C implementations). The bug fix was double-confirmed by independent review passes and reproduced/validated with a standalone C harness (buggy:cdf(1e10, 20, 20, 10) == 0.0; fixed:1.0; all in-support and NaN/±infinity cases unchanged), plus a syntax check against the package headers. Deliberately excluded: anything subjective, interpretive, or requiring changes outside the reviewed diff window. The ULP-based test migrations, bot docs commits, and the clean-up commit were reviewed and found clean.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code as part of a scheduled automated review of commits recently merged to
develop; findings were cross-validated by independent review passes and the fix was verified with a standalone C harness.🤖 Generated with Claude Code
https://claude.ai/code/session_01E8PkS1AQnkLGgAAEiFeQq7
Generated by Claude Code