powered by
mod(n, m) rem(n, m) idivide(n, m, rounding = c("fix", "floor", "ceil", "round"))
mod(n, m)
mod(n, 0)
n
m
rem(n, m) is the same modulo operator and returns $n\,mod\,m$. mod(n, 0) is NaN, and the result always has the same sign as n.
rem(n, m)
NaN
idivide(n, m) is integer division, with the same effect as n %/% m or using an optional rounding mode.
idivide(n, m)
n %/% m
%/%
%%
mod(c(-5:5), 5) rem(c(-5:5), 5) idivide(c(-2, 2), 3, "fix") # 0 0 idivide(c(-2, 2), 3, "floor") # -1 0 idivide(c(-2, 2), 3, "ceil") # 0 1 idivide(c(-2, 2), 3, "round") # -1 1
Run the code above in your browser using DataLab