MATLAB Function Reference | Search  Help Desk |
rem | See Also |
R = rem(X,Y)
R = rem(X,Y)
returns X - fix(X./Y).
*Y
, where fix(X./Y)
is the integer part of the quotient, X./Y
.
So long as operands X
and Y
are of the same sign, the statement rem(X,Y)
returns the same result as does mod(X,Y)
. However, for positive X
and Y
,
rem(-x,y) = mod(-x,y)-yThe
rem
function returns a result that is between 0 and sign(X)*abs(Y)
. If Y
is zero, rem
returns NaN
.
Arguments X
and Y
should be integers. Due to the inexact representation of floating-point numbers on a computer, real (or complex) inputs may lead to unexpected results.
mod
Modulus (signed remainder after division)