Remainder after division

- example
`R = rem(X,Y)`

`R = rem(`

returns
the remainder after division of `X`

,`Y`

)`X`

by `Y`

.
In general, if `Y`

does not equal `0`

, ```
R
= rem(X,Y)
```

returns `X - n.*Y`

, where ```
n
= fix(X./Y)
```

. If `Y`

is not an integer
and the quotient `X./Y`

is within roundoff error
of an integer, then `n`

is that integer. Inputs `X`

and `Y`

must
have the same dimensions unless one of them is a scalar double. If
one of the inputs has an integer data type, then the other input must
be of the same integer data type or be a scalar double.

The following are true by convention:

`rem(X,0)`

is`NaN`

.`rem(X,X)`

for`X~=0`

is`0`

.`rem(X,Y)`

for`X~=Y`

and`Y~=0`

has the same sign as`X`

.

Was this topic helpful?