devxlogo

The fmod() Function

The fmod() Function

The modulus operator can only be applied to integral types. To compute the remainder of two floating point variables, you have to use the fmod() function instead. Fmod() is declared in (formerly: ) as follows:

 double fmod(double x, double y);

fmod() calculates x modulo y, which is the remainder of x/y. When y is 0, fmod() returns 0.

The Standard Library defines another version of this function called fmodl(), which is identical to fmod() except that it takes and returns variables of type long double.

See also  5 Strategies for Supercharging Your CRM
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist