div: Integer Division

Description Usage Arguments Details Value See Also Examples

View source: R/modular.R

Description

Integer division.

Usage

1
div(n, m)

Arguments

n

numeric vector (preferably of integers)

m

integer vector (positive, zero, or negative)

Details

div(n, m) is integer division, that is discards the fractional part, with the same effect as n %/% m. It can be defined as floor(n/m).

Value

A numeric (integer) value or vector/matrix.

See Also

mod, rem

Examples

1
2
3
4
div(c(-5:5), 5)
div(c(-5:5), -5)
div(c(1, -1), 0)  #=> Inf -Inf
div(0,c(0, 1))    #=> NaN  0      

Example output

 [1] -1 -1 -1 -1 -1  0  0  0  0  0  1
 [1]  1  0  0  0  0  0 -1 -1 -1 -1 -1
[1]  Inf -Inf
[1] NaN   0

numbers documentation built on May 15, 2021, 1:08 a.m.