Repository navigation
Fix randomInt rounding at the upper bound - #52
Open
Zhuyuyangyy wants to merge 1 commit into
Open
Zhuyuyangyy wants to merge 1 commit into
Zhuyuyangyy wants to merge 1 commit into
Conversation
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.
Fixes #51 by applying the floor-first ordering suggested in the report.
When a legal source returns the largest double below one, adding an integer offset before flooring can round the sum up to the excluded upper bound. For example:
The same problem occurs with positive intervals and large safe-integer offsets. The production change is one line: floor the sampled range offset first, then add the integer lower bound. Bounds are normalized as before, and the source is still called once per sample. This does not add parameter validation or attempt to solve Number precision limitations outside safe-integer bounds.
Six deterministic tests cover negative and positive intervals, a large offset, the single-argument form, fractional-bound normalization, and legal source values at zero, near one, and a binary midpoint. No versions, dependency declarations, lockfiles, or generated distributions are changed.
Local validation
On Node 24.19.0 with Mocha 8.4.0, ESLint 7.28.0, and d3-array 2.12.1 (within the declared ranges):
npm test: 73 passing, ESLint passes.git diff --check: passes.These are local results, not a claim that upstream CI has passed. Other Node versions and real-browser runtimes were not tested.
AI assistance
This change and its tests were prepared with AI assistance on behalf of the account owner. It has not received an independent human review.