Repository navigation
Conversation
AmanBoronbaev
left a comment
There was a problem hiding this comment.
I tried the zero-dividend case with a negative divisor on 0146c35. With x = 0.00 and y = -1, fresh outputs give q = -0 and r = 0.00. Reusing x as the quotient gives q = -0 and r = -0.00; r.Signbit() changes solely because the destination aliases x.
In the zero branch, z.setZero writes the quotient sign into x when z == x. The subsequent r.setZero then reads that updated x.form. Could you save the dividend sign before writing either output, as you do for the exponent, and include this combination in the alias tests? The rational comparison in TestQuoRemScale considers both signed zeros equal, so an explicit Signbit assertion would catch it. The sign issue also applies to the previous zero branch.
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.
QuoRem(1.2, 1)currently returns(1, 2)instead of(1, 0.2). The coefficient division aligns both operands but does not restore the remainder's exponent. The multiprecision path can also retain a previously used quotient receiver's exponent.Restore the integer quotient exponent and the common operand exponent for the remainder in
Context.QuoRem, matching the responsibilities already handled byQuoIntandRem. Capture the common exponent before division so input/output aliasing is safe, and use it for zero dividends as well.Fixes #187.
Tests compare both public entry points with exact
math/bigrational results across compact and multiprecision operands, signs, zero, reused receivers, and input/output aliases. The regression fails before the fix.Validation (Go 1.27.1/Linux arm64):
go test -short -count=1 -skip 'TestDecTests|TestPytables|TestIssue69' ./...go test -race -run 'Quo|Rem|TestIssue72' -count=1 .go vet ./...All above pass. Generated decimal/Python test corpora are absent locally. The exhaustive float/square-root tests were not completed; an initial full race run was stopped under the local resource budget, then the short and focused checks above were run.