s-u / fastmatch

Fast hashing functions and replacement of match()
18 stars 7 forks source link

-0 is never matched #12

Closed qzhang503 closed 9 months ago

qzhang503 commented 9 months ago

different outputs

xs <- ceiling(log(c(114.0916, 114.9999)/115)/log(1+1E-6)) match(xs, xs); fastmatch::fmatch(xs, xs)

the same outputs

ys <- as.integer(xs) match(ys, ys); fastmatch::fmatch(ys, ys)

s-u commented 9 months ago

Thanks, the normalization of zero in doubles didn't quite work as designed since the normalized value (0) was compared to the original (-0) and thus -0 would never match - most simple example:

> fastmatch::fmatch(-0,-0)
[1] NA

now fixed

> fastmatch::fmatch(c(0,-0),-0)
[1] 1 1