There's a common rounding pattern throughout phash.cpp like (int)std::floor(d + ROUNDING_FACTOR(d)) where ROUNDING_FACTOR is #define ROUNDING_FACTOR(x) (((x) >= 0) ? 0.5 : -0.5). This produces some unusual results:
Hi @ams2990 you’re right this does seem like a bug. I’m not sure the rounding mode matters much as long as it’s consistent. Would be happy to review a PR.
There's a common rounding pattern throughout phash.cpp like
(int)std::floor(d + ROUNDING_FACTOR(d))
where ROUNDING_FACTOR is#define ROUNDING_FACTOR(x) (((x) >= 0) ? 0.5 : -0.5)
. This produces some unusual results:The weirdest one there is -0.75 rounds to -2, which seems wrong. I'd be happy to fix this, but I can't tell what the desired behavior is.