numpy.fmod

numpy.fmod(x1, x2[, out])

Return the remainder of division.

This is the NumPy implementation of the C modulo operator %.

Parameters:

x1 : array_like

Dividend.

x2 : array_like

Divisor.

Returns:

y : array_like

The remainder of the division of x1 by x2.

See also

mod
Modulo operation where the quotient is floor(x1,x2).

Notes

The result of the modulo operation for negative dividend and divisors is bound by conventions. In fmod, the sign of the remainder is the sign of the dividend, and the sign of the divisor has no influence on the results.

Examples

>>> np.fmod([-3, -2, -1, 1, 2, 3], 2)
array([-1,  0, -1,  1,  0,  1])
>>> np.mod([-3, -2, -1, 1, 2, 3], 2)
array([1, 0, 1, 1, 0, 1])

Previous topic

numpy.floor_divide

Next topic

numpy.mod

This Page

Quick search