Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative number modulus *big.Int behaves differently to int #117

Closed
wader opened this issue Aug 16, 2021 · 2 comments
Closed

Negative number modulus *big.Int behaves differently to int #117

wader opened this issue Aug 16, 2021 · 2 comments

Comments

@wader
Copy link
Contributor

wader commented Aug 16, 2021

$ go run cmd/gojq/main.go -n '2147483647 as $maxHalfInt | -1 % ($maxHalfInt, $maxHalfInt+1)'
-1
2147483647

Im not that familiar with modulus math but the comment for *big.Int Mod might be a clue:

Mod sets z to the modulus x%y for y != 0 and returns z. If y == 0, a division-by-zero run-time panic occurs. Mod implements Euclidean modulus (unlike Go); see DivMod for more details.

@itchyny
Copy link
Owner

itchyny commented Aug 16, 2021

Fixed, thanks.

@wader
Copy link
Contributor Author

wader commented Aug 16, 2021

👍 thanks for quick fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants