-
-
Notifications
You must be signed in to change notification settings - Fork 216
Python semantics for mod of negative int #365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Well it's not practical to add new op-codes in version 2.7, as they're all used up. So it would imply changing the behavior of NumExpr to use the sign of the divisor to remain consistent in the Python eco-system. I'm inclined to change it because NumExpr isn't consistent, if you use literals,
the result is the expected Python value
The actual functions are as follows; for integer mod (from
and for floating-point mod:
So basically I need a macro for
This is ugly, there's probably a faster implementation out there somewhere. |
The implementation of http://www.netlib.org/fdlibm/s_copysign.c I'm guessing there's some slick way to do it with bit-shift operations for integers. NumPy's implementation appears to be rather naive: |
Message to comment on stale issues. If none provided, will not mark issues stale |
AFAICT ne.evaluate is using C semantics for divmod, rounding the div towards zero instead of towards -inf. It would be nice if we could enable python semantics here, analogous to
@cython.cdivision(False)
The text was updated successfully, but these errors were encountered: