mod - Modulo function

Prev Next

Function Names

mod

Description

Calculates the remainder (modulo) of a value.


Vectorization: This function supports vectorization in the 1st and 2nd function parameter. Instead of providing a single value, you can provide a set or even a nested set which contain multiple values. The function will then process every value and its return value contains a corresponding set containing all results.

Call as: function

Restrictions

Indirect parameter passing is disabled
Vectorization is allowed in the 1st and 2nd function parameters

Parameter count

2

Parameters

No.TypeDescription
1.
input
numeral
set
Divisor

Value or set containing values (vectorization) to divide by dividend

2.
input
numeral
set
Dividend

Dividend value or set containing values (vectorization) is used for the division following extracting the remainder value

Return value

TypeDescription
numeral
set
Remainder

Calculated remainder

Exceptions

Values provided is not a numerals
rounding intervals is negative or zero

Examples

               for all( { {10, 3}, {10.25,0.02}, {10.5, 2} }, p[] )
                       echo( p[]{0}, " mod ", p[]{1}, " = ", mod( p[]{0}, p[]{1} ) );
               

Output

10 mod 3 = 1
10.25 mod 0.02 = 0.01
10.5 mod 2 = 0.5
Try it yourself: Open LIB_Function_mod.b4p in B4P_Examples.zip. Decompress before use.