Guardian C Library Calls Reference Manual
Reference to Library Calls
Guardian TNS C Library Calls Reference Manual—128833 3-47
fmod
fmod
The fmod function computes the floating-point remainder of the division of its
arguments.
divid
is an expression of type double, specifying the dividend.
divis
is an expression of type double, specifying the divisor.
Return Value
is the floating-point remainder of the division of (divid/divis), expressed as a double
value with the same sign as divid and a magnitude less than divis. If divis is zero,
fmod returns the value of divid.
Usage Guidelines
•
The fmod function is equivalent to the following, provided that divid and divis are
expressions without side effects:
modf((divid/divis), &int_part);
return_value = divid - (int_part*divis);
Example
This example prints “The remainder is 1.000000.”:
#include <mathh>
#include <stdioh>
int main(void)
{
double r, x, y;
x = 5.0;
y = 2.0;
r = fmod(x, y);
printf ("The remainder is %f.", r);
}
#include <mathh>
double fmod(double divid, double divis);