Skip to Main Content Skip to Search
Product Documentation

rem - Remainder after division

Syntax

R = rem(X,Y)

Description

R = rem(X,Y) if Y ~= 0, 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. The inputs X and Y must be real arrays of the same size, or real scalars.

The following are true by convention:

Tips

mod(X,Y) for X~=Y and Y~=0 has the same sign as Y.

rem(X,Y) and mod(X,Y) are equal if X and Y have the same sign, but differ by Y if X and Y have different signs.

The rem function returns a result that is between 0 and sign(X)*abs(Y). If Y is zero, rem returns NaN.

See Also

mod

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS