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

The division of Long.MIN_VALUE / -1 overflows #20

Open
smarr opened this issue Feb 12, 2019 · 0 comments
Open

The division of Long.MIN_VALUE / -1 overflows #20

smarr opened this issue Feb 12, 2019 · 0 comments
Labels

Comments

@smarr
Copy link
Member

smarr commented Feb 12, 2019

Normally, we handle overflows with Math.*Exact operations, but we don't have one in this case, because:

In cases where the size is int or long and overflow errors need to be detected, the methods addExact, subtractExact, multiplyExact, and toIntExact throw an ArithmeticException when the results overflow. For other arithmetic operations such as divide, absolute value, increment, decrement, and negation overflow occurs only with a specific minimum or maximum value and should be checked against the minimum or maximum as appropriate.

See https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html

Possible solution proposed by @fniephaus: smarr/SOMns#292

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

No branches or pull requests

1 participant