devxlogo

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.

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Seven Service Boundary Mistakes That Create Technical Debt

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.