mod: Modulo Operator

Description Usage Arguments Details Value Note See Also Examples

View source: R/modular.R

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

numbers documentation built on May 31, 2017, 5:14 a.m.