Commit 4f8ba2bf authored by Robert Bradshaw's avatar Robert Bradshaw

Tests for c division CEP 516

parent 0fdf2f78
__doc__ = u"""
>>> v = [(17, 10), (-17, 10), (-17, -10), (17, -10)]
>>> standard = [(a % b) for a, b in v]
>>> standard
[7, 3, -7, -3]
>>> [mod_int_py(a, b) for a, b in v] == standard
True
>>> [mod_short_py(a, b) for a, b in v] == standard
True
>>> [mod_float_py(a, b) for a, b in v] == standard
True
>>> [mod_double_py(a, b) for a, b in v] == standard
True
>>> [mod_int_c(a, b) for a, b in v]
[7, -7, -7, 7]
>>> [mod_float_c(a, b) for a, b in v]
[7.0, -7.0, -7.0, 7.0]
>>> [mod_double_c(a, b) for a, b in v]
[7.0, -7.0, -7.0, 7.0]
"""
cimport cython
@cython.cdivision(False)
def mod_int_py(int a, int b):
return a % b
@cython.cdivision(False)
def mod_short_py(short a, short b):
return a % b
@cython.cdivision(False)
def mod_double_py(double a, double b):
return a % b
@cython.cdivision(False)
def mod_float_py(float a, float b):
return a % b
@cython.cdivision(True)
def mod_int_c(int a, int b):
return a % b
@cython.cdivision(True)
def mod_float_c(float a, float b):
return a % b
@cython.cdivision(True)
def mod_double_c(double a, double b):
return a % b
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment