On this page
numpy.mod
numpy.mod(x1, x2[, out]) =
-
Return element-wise remainder of division.
Computes
x1 - floor(x1 / x2) * x2
, the result has the same sign as the divisorx2
. It is equivalent to the Python modulus operatorx1 % x2
and should not be confused with the Matlab(TM)rem
function.Parameters: x1 : array_like
Dividend array.
x2 : array_like
Divisor array.
out : ndarray, optional
Array into which the output is placed. Its type is preserved and it must be of the right shape to hold the output. See doc.ufuncs.
Returns: y : ndarray
The remainder of the quotient
x1/x2
, element-wise. Returns a scalar if bothx1
andx2
are scalars.Notes
Returns 0 when
x2
is 0 and bothx1
andx2
are (arrays of) integers.Examples
>>> np.remainder([4, 7], [2, 3]) array([0, 1]) >>> np.remainder(np.arange(7), 5) array([0, 1, 2, 3, 4, 0, 1])
© 2008–2016 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.mod.html