Wrong rounding mode in nearbyint_as_int testcase
sh1boot opened this issue · 0 comments
sh1boot commented
Depending on test set-up, test cases for rounding can come out with exact halfway cases. Consequently the rounding mode becomes important. The current reference implementation for nearbyint_as_int()
uses lround()
:
https://github.com/xtensor-stack/xsimd/blob/61d389c87f61ca5575c77369ec5068ea450f716e/test/test_rounding.cpp#L21C25-L21C25
But these have incompatible rounding policies:
https://en.cppreference.com/w/cpp/numeric/math/nearbyint -- current rounding mode
https://en.cppreference.com/w/c/numeric/math/round -- halfway cases away from zero
I notice it didn't come up when I tested a 256-bit implementation, but stung me when I ran the same tests in a 128-bit configuration.