numpy.mod(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'remainder'>
Return elementwise remainder of division.
Computes the remainder complementary to the floor_divide
function. It is equivalent to the Python modulus operator``x1 % x2`` and has the same sign as the divisor x2
. The MATLAB function equivalent to np.remainder
is mod
.
Warning
This should not be confused with:
math.remainder
and C’s remainder
, which computes the IEEE remainder, which are the complement to round(x1 / x2)
.rem
function and or the C %
operator which is the complement to int(x1 / x2)
.Parameters: 


Returns: 

See also
floor_divide
//
operator.divmod
fmod
rem
function.Returns 0 when x2
is 0 and both x1
and x2
are (arrays of) integers. mod
is an alias of remainder
.
>>> np.remainder([4, 7], [2, 3]) array([0, 1]) >>> np.remainder(np.arange(7), 5) array([0, 1, 2, 3, 4, 0, 1])
© 2005–2019 NumPy Developers
Licensed under the 3clause BSD License.
https://docs.scipy.org/doc/numpy1.17.0/reference/generated/numpy.mod.html