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

Euclidean breaks when Int overflow occurs #269

Open
schlichtanders opened this issue Jan 17, 2025 · 0 comments
Open

Euclidean breaks when Int overflow occurs #269

schlichtanders opened this issue Jan 17, 2025 · 0 comments

Comments

@schlichtanders
Copy link

julia> Distances.evaluate(Euclidean(), Int16(-1360), Int16(-136))
ERROR: DomainError with -9152.0:
sqrt was called with a negative real argument but will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
Stacktrace:
 [1] throw_complex_domainerror(f::Symbol, x::Float64)
   @ Base.Math ./math.jl:33
 [2] sqrt
   @ ./math.jl:608 [inlined]
 [3] sqrt
   @ ./math.jl:1531 [inlined]
 [4] eval_end
   @ ~/.julia/packages/Distances/mlz7p/src/metrics.jl:336 [inlined]
 [5] _evaluate
   @ ~/.julia/packages/Distances/mlz7p/src/metrics.jl:314 [inlined]
 [6] Euclidean
   @ ~/.julia/packages/Distances/mlz7p/src/metrics.jl:331 [inlined]
 [7] evaluate(dist::Euclidean, a::Int16, b::Int16)
   @ Distances ~/.julia/packages/Distances/mlz7p/src/generic.jl:47
 [8] top-level scope
   @ REPL[32]:1

julia> Distances.eval_op(Euclidean(), Int16(-1360), Int16(-136))
-9152

Would be nice if instead of an error, the typemax is returned, ideally with a check whether the operations are incurring an overflow

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

1 participant