numpy/numpy-user-dtypes

SleefQuadPrecision np.mod ufunc gives unexpected results

Closed this issue · 3 comments

The numpy docs state about np.mod that

It is equivalent to the Python modulus operator x1 % x2 and has the same sign as the divisor x2

For [-1.1, -1.0, -0.9, -0.1, 0.0, 0.1, 0.9, 1.0, 1.1], float64 mod +1 gives [0.9, 0.0, 0.1, 0.9, 0.0, 0.1, 0.9, 0.0, 0.1] and mod -1 [-0.1, -0.0, -0.9, -0.1, -0.0, -0.9, -0.1, -0.0, -0.9], but sleef gives [-0.1, -0.0, -0.9, -0.1, 0.0, 0.1, 0.9, 0.1] for both mod +1 and mod -1.

(this is because numpy's remainder definition differs from the one used in sleef)

Thanks for pointing this out, will update the definition to match with NumPy

Fixed by #125