Main Content

modByConstant

Modulus after division by a constant denominator

Since R2021a

Description

Y = modByConstant(X,d) performs the modulo operation (remainder after division) of X with respect to the denominator d.

For simulation, the data type of the output Y is chosen based on the value of the denominator d and the range of X.

To generate code, the denominator d must be a constant.

example

Examples

collapse all

modByConstant(fi(10203),10)
ans = 

     3

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 5
        FractionLength: 1
modByConstant(uint16(6930),1024)
ans = 

   786

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 10
        FractionLength: 0

Input Arguments

collapse all

Dividend, specified as a scalar, vector, matrix, or multidimensional array.

If X is a fixed-point or scaled-double fi, it must use binary point scaling.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | fi

Divisor, specified as a positive, real-valued scalar.

If d is a fixed-point or scaled-double fi, it must use binary point scaling.

To generate code, the denominator d must be a constant.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | fi

Output Arguments

collapse all

Result of modulus operation, returned as a scalar, vector, matrix, or multidimensional array.

For simulation, the data type of the output Y is chosen based on the value of the denominator d and the range of X.

Extended Capabilities

Version History

Introduced in R2021a