You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is that sort! gives the wrong order due to the -0.0. It uses the order relation <, which ultimately calls the following Base function:
functioncmp(A::AbstractVector, B::AbstractVector)
for (a, b) inzip(A, B)
if!isequal(a, b)
returnisless(a, b) ?-1:1endendreturncmp(length(A), length(B))
end
Here, isequal distinguishes 0.0 and -0.0 and thus sort! outputs [-0.0, 2] before [2.0, 0]. The remaining algorithm checks right turns, which are not precise enough to see the difference, and thus gives the wrong result.
The following happens because of the
-0.0
. Nevertheless, the result is unexpected.The text was updated successfully, but these errors were encountered: