Description
Computes the fractional remainder of the division (x/y). This modulo calculation can also be performed using the syntax: x%y. The fmod function requires y to be greater than zero, while the % syntax allows negative values for y.
Timing Precision Mode
This page describes functionality in nanosecond timing precision mode.
Function Signature
Arguments
x
|
|
Description:
|
Numerator used in the division calculation.
|
y
|
|
Description:
|
Denominator used in the division calculation.
|
Valid Range:
|
y > 0
|
Return Value
The fractional remainder of the division (x/y).
Syntax
myVariable1 = fmod(myVariable2, myVariable3);
|
This example demonstrates the use of the function fmod(x,y). 'x%y' has equivalent functionality, and the two can be used interchangeably for y>0.
// 5/5 has no remainder.
Report fmod(5,5), 5%5;
// -5/2 has remainder -1.
Report fmod(-5,2), -5%2;
// 5/.3 has remainder .2.
Report fmod(5,.3), 5%.3;
|
Output Report:
fmod(5,5) = 0
5%5 = 0
fmod(-5,2) = -1
-5%2 = -1
fmod(5,.3) = .2
5%.3 = .2
|
This example demonstrates further use of '%'.
// The '%' operator can also be used with a negative denominator.
// This functionality is not available for fmod(x,y).
Report 5%-3, 5%3;
|
Output Report:
|
See also
fmod
|