mod: Modulo Operator

Description Usage Arguments Details Value Note See Also Examples

Description

Modulo operator.

Usage

1
mod(n, m)

Arguments

n

numeric vector (preferably of integers)

m

integer vector (positive, zero, or negative)

Details

mod(n, m) is the modulo operator and returns n\,mod\,m. mod(n, 0) is n, and the result always has the same sign as m.

Value

a numeric (integer) value or vector/matrix

Note

The following relation is fulfilled (for m != 0):

mod(n, m) = n - m * floor(n/m)

See Also

rem, div

Examples

1
2
3
4
mod(c(-5:5), 5)
mod(c(-5:5), -5)
mod(0, 1)         #=> 0
mod(1, 0)         #=> 1


Search within the numbers package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.