Repository navigation
Keep binary prefixes below their exact size thresholds - #71
Merged
wolph merged 1 commit intoNov 1, 2026
Merged
Conversation
wolph
added a commit
that referenced
this pull request
Nov 1, 2026
#71 #71 compares the input with the exact integer threshold before the float conversion. A numeric type that defines __le__ and __float__ but not __lt__ passed on 4.1.4 and raised TypeError on that comparison. Only an int needs the exact comparison, so every other type goes through float() as 4.1.4 did. A test pins such a type.
wolph
added a commit
that referenced
this pull request
Nov 1, 2026
Owner
|
Thank you for the fix and the thorough tests! I've kept the exact comparison for ints only, so a numeric type without |
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.
scale_1024(1024**5 - 1, 9)currently returns(0.9999999999999991, 5), selecting PiB before the input reaches one PiB. The logarithm also rounds the float immediately below 1024 up to the KiB boundary.Check the estimated prefix against its exact integer threshold before converting the input to float, and lower it when the threshold has not been reached. This preserves the existing scaling calculation, available-prefix limit and handling of small or nonpositive inputs. Document how prefix boundaries are selected.
Regression coverage checks integer and adjacent representable float values below, at and above all eight binary-prefix boundaries, plus a capped-prefix control. Against unchanged develop, 12 of the 17 new parametrized cases fail and 5 pass; all pass after the fix.
Validation on Windows:
git diff --checkpasses.Checked current contribution instructions and existing issues/PRs; no overlapping open fix was found.
AI assistance: OpenAI Codex investigated, implemented and tested this change at the account owner's request,
new 1ta koro(make one new contribution). No independent human review is claimed.