Rounding logic looks strange
ams2990 opened this issue · 1 comments
ams2990 commented
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:
-1.0 → -2
-0.75 → -2
-0.5 → -1
-0.25 → -1
0.0 → 0
0.25 → 0
0.5 → 1
0.75 → 1
1.0 → 1
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.