numbers (version 0.7-5)

mod: Modulo Operator

Description

Modulo operator.

Usage

mod(n, m)

Arguments

n

numeric vector (preferably of integers)

m

integer vector (positive, zero, or negative)

Value

a numeric (integer) value or vector/matrix

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.

See Also

rem, div

Examples

Run this code
# NOT RUN {
mod(c(-5:5), 5)
mod(c(-5:5), -5)
mod(0, 1)         #=> 0
mod(1, 0)         #=> 1
# }

Run the code above in your browser using DataCamp Workspace