Skip to content

isapprox can give absurd result in case of integer overflow #50380

@nalimilan

Description

@nalimilan

I was surprised to realize this:

julia> Int8(-68)  Int8(60)
true

This is because of the way the isapprox fallback is defined, and more precisely to:

julia> abs(Int8(-68) - Int8(60))
-128

Shouldn't we define a custom method for integers that is robust to overflow?

Metadata

Metadata

Assignees

No one assigned

    Labels

    correctness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwingmathsMathematical functions

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions