Navigation

Operators and Keywords

Function List:

C++ API

: rem (x, y)

Return the remainder of the division x / y.

The remainder is computed using the expression

x - y .* fix (x ./ y)

An error message is printed if the dimensions of the arguments do not agree, or if either argument is complex.

Programming Notes: Floating point numbers within a few eps of an integer will be rounded to an integer before computation for compatibility with MATLAB.

By convention,

rem (x, 0) = NaN  if x is a floating point variable
rem (x, 0) = 0    if x is an integer variable
rem (x, y)        returns a value with the signbit from x

For the opposite conventions see the mod function. In general, rem is best when computing the remainder after division of two positive numbers. For negative numbers, or when the values are periodic, mod is a better choice.

See also: mod.

Package: octave