Table Of Contents


    Last Modified: January 9, 2017

    Computes the modulo of the input elements.


    c = mod(a, b)



    Dividend. a is a non-complex scalar or non-complex array of any dimension.


    Divisor. b is a non-complex scalar or non-complex array of the same dimension as a. If one input is an array, the other input can also be a scalar.



    Modulo of a and b. c has the same sign as b. c is a matrix of the same size as the larger of a and b. The output data type is the smaller data type of the two inputs. For example, if one input is double precision and the other input is single precision floating point number, the output is a single precision floating-point number.

    Calculation Formula

    MathScript uses the following equation: mod(a, b) = a-b.*floor(a./b).

    Special Cases

    If a is positive, mod(a, 1) is the fractional part of a. If the input elements have the same sign, mod(a, b) is equivalent to rem(a, b). If one input is an integer type, the other must be the same integer type or a double scalar type.

    A = 5
    B = 3
    C = mod(A, B)

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: Not supported

    Recently Viewed Topics