Everything

fmod / fmodf / fmodl


Calculates the remainder of a division of two floating-point numbers.

[Format]

#include <math.h>

double fmod (double x, double y);

float fmodf (float x, float y);

long double fmodl (long double x, long double y);

[Parameters]

x Dividend

y Divisor

[Return values]

When y is 0.0: x

When y is not 0.0: Remainder of division of x by y

When y is ±∞: Returns x.

When x is ±∞ or y is 0: Returns not-a-number and sets global variable errno to the value of macro EDOM.

[Remarks]

In the fmod function, the relationship between parameters x and y and return value ret is as follows:

x = y * i + ret (where i is an integer)

The sign of return value ret is the same as the sign of x.

If the quotient of x/y cannot be represented, the value of the result is not guaranteed.