REM calculates remainder of X / Y z = x - y * fix(x/y); e = eps * fix(x/y); [z,e] = REM(X,Y) z is the remainder of X / Y e is the error tolerance, for checking the accuracy z(e > abs(y)) is not defined z has always the same sign than x see also: MOD