fmod() Calculate Floating-Point Remainder
#include <math.h> Required for declarations only
double fmod(x,y);
double x; Floating-point dividend
double y; Floating-point divisor
fmod() returns the remainder of 'x'/'y'. The remainder (r) will have
the same sign as 'x'; the absolute value of (r) will be less than the
absolute value of 'y'; and the following equation will be true:
(x == i * y + r)
where (i) is a signed integer and (r) is the value returned by
fmod().
Returns: Remainder of 'x'/'y'. If 'y' is 0.0 then 0.0 is
returned.
-------------------------------- Example ---------------------------------
The following statements calculate the floating point remainders of
-15.0 / 4.0, 6.1 / -2.5 and 5.5 / 0.0:
#include <math.h> /* Required for function definition only */
main()
{
double x, y, z;
x = fmod(-15.0, 4.0); /* x = -3.0 */
y = fmod(6.1, -2.5); /* y = 1.1 */
z = fmod(5.5, 0.0); /* z = 0.0 */
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster