Skip to content

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

Open
@smarr

Description

@smarr

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions