Skip to content

fix: perform support checks before integer narrowing - #14933

Merged
kgryte merged 4 commits into
developfrom
philipp/fix-commit-review-2026-09-03
Sep 4, 2026
Merged

fix: perform support checks before integer narrowing#14933
kgryte merged 4 commits into
developfrom
philipp/fix-commit-review-2026-09-03

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

Follow-up fixes for commits merged to develop between f29c023 (2026-09-03 02:05 +0530) and d656eba (2026-09-03 11:31 +0500).

This pull request:

  • stats/base/dists/hypergeometric/cdf:
    • Fixes the double-to-int32 truncation order in stats/base/dists/hypergeometric/cdf: f29c023be's main.c cast x to int32_t before the support-bound checks, so any finite x outside int32 range hit UB (INT32_MIN on x86-64) and cdf(1.0e10, 20, 20, 10) wrongly returned 0.0 instead of 1.0. Now lib/node_modules/@stdlib/stats/base/dists/hypergeometric/cdf/src/main.c truncates into a double and compares against (double)lower/(double)upper before narrowing, matching the JS reference; verified against a standalone harness for 1e10/1e300 plus in-support values.
    • Fixes the CDF doc comment in src/main.c (f29c023) — it was missing the N/K/n/x parameter clause present in cdf.h, lib/native.js, lib/main.js, and the quantile package's src/main.c. Restored it for consistency.

Related Issues

Does this pull request have any related issues?

No.

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.

Validation. All 20 commits merged to develop in 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-equal for blas/ext/index-of-falsy; stats/base/dists/hypergeometric/pmf/logpmf for 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

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • 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.".

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

…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
@stdlib-bot stdlib-bot added the Statistics Issue or pull request related to statistical functionality. label Sep 3, 2026
@stdlib-bot

stdlib-bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

No coverage information available.

Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
@kgryte
kgryte marked this pull request as ready for review September 4, 2026 05:28
@kgryte
kgryte requested a review from a team September 4, 2026 05:28
kgryte
kgryte previously approved these changes Sep 4, 2026
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 4, 2026
@kgryte kgryte changed the title fix: perform support checks before integer narrowing in stats/base/dists/hypergeometric/cdf fix: perform support checks before integer narrowing Sep 4, 2026
@kgryte
kgryte merged commit 493166d into develop Sep 4, 2026
12 checks passed
@kgryte
kgryte deleted the philipp/fix-commit-review-2026-09-03 branch September 4, 2026 09:48
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants