RAD Studio |  |

fmod, fmodl

Header File

math.h

Category

Math Routines

Prototype

double fmod(double x, double y);

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

Description

Calculates x modulo y, the remainder of x/y.

fmod calculates x modulo y (the remainder f, where x = ay + f for some integer a, and 0 < f < y).

fmodl is the long double version; it takes long double arguments and returns a long double result.

Return Value

fmod and fmodl return the remainder f where x = ay + f (as described above). When y = 0, fmod and fmodl return 0.

Example

Copy Code

    #include <stdio.h>
    #include <math.h>
    int main(void)
    {
       double x = 5.0, y = 2.0;
       double result;
       result = fmod(x,y);
       printf("The remainder of (%lf / %lf) is %lf\n", x, y, result);
       return 0;
    }

Portability

| POSIX | Win32 | ANSI C | ANSI C++
fmod | + | + | + | +
fmodl |  | + | + | +

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!