Synopsis
#include <math.h>
double fmod(double x, double y);
Description

fmod computes the floating-point remainder of x divided by y. fmod returns the value x - ny, for some integer n such that, if y is nonzero, the result has the same sign as x and magnitude less than the magnitude of y.

Fast math library behavior

If y = 0, fmod returns zero and errno is set to EDOM.

IEC 60559 math library behavior

fmod(±0, y) is ±0 for y not zero.
fmod(∞, y) is NaN and raises the “invalid” floating-point exception.
fmod(x, 0) is NaN and raises the “invalid” floating-point exception.
fmod(x, ±∞) is x for x not infinite.

Portability

fmod conforms to ISO/IEC 9899:1990 (C90) and ISO/IEC 9899:1999 (C99).