Navigation

Operators and Keywords

Function List:

C++ API

Mapping Function: mod (x, y)

Compute the modulo of x and y.

Conceptually this is given by

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

and is written such that the correct modulus is returned for integer types. This function handles negative values correctly. That is, mod (-1, 3) is 2, not -1, as rem (-1, 3) returns. mod (x, 0) returns x.

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

See also: rem.

Package: octave