The MoD function uses the Floor,rem function with the fix function. So what is floor and fix?
- Fix (x): Truncate rounding. Such as:
>> fix ([3.4,-3.4])
Ans =
3-3
- Floor (x): Gaussian rounding (no more than the largest integer of x). Such as:
>> floor ([3.4,-3.4])
Ans =
3-4
PS: By the way, the other two rounding functions Ceil () and round ()
Ceil (x): the smallest integer greater than X. Such as:
>> Ceil ([3.4,-3.4])
Ans =
4-3
Round (x): Rounds rounding. Such as:
>> round ([3.4, 3.6,-3.4,-3.6])
Ans =
3 4-3-4
The summary is: fix in the direction of 0 rounding, floor in the negative Infinity direction rounding, ceil in the positive Infinity direction rounding, round rounded to the nearest integer
Here are the things that go back to modulo ...
The formula is: value = divisor-(quotient * divisor) (quotient is obtained through floor function)
such as mod (-1000, 201) =-1000-(-5 * 201) = 5
and mod (1000,-201) = 1000-(-5 *-201) = 5
REM, in the same vein, is calculated using this formula, but it is a fix function. The same applies for decimals.
Matlab to take the model and take the remainder