The test isequal(+0.0,-0.0) returns FALSE

What you might do is something like:

unique(x -> round(x, sigdigits=13), myarray)

which would perform the unique operation based on the first 13 significant digits. (You could use digits instead of sigdigits if you want an absolute tolerance).

But this might not necessarily be what you want, e.g. unique(x -> round(x, sigdigits=13), [1.000000000000501, 1.0000000000005]) gives [1.000000000000501, 1.0000000000005] because those two values round differently in the 13th decimal digit. (Again, the fact that approximate equality is not an equivalence relation — it’s not transitive — means that any implementation of unique with a tolerance will have some odd behaviors.)

4 Likes