fmod() in C: Floating-Point Remainder

fmod() returns the floating-point remainder of x / y. The result has the same sign as x. It is different from the integer-only % operator.

Syntax Top ↑

double fmod(double x, double y);

Floating-Point Remainder Top ↑

#include <math.h>
#include <stdio.h>

int main(void) {
    double x = 17.5;
    double y = 4.0;

    printf("Remainder: %.2f\n", fmod(x, y));
    return 0;
}

Output

Remainder: 1.50

Negative Dividend Top ↑

#include <math.h>
#include <stdio.h>

int main(void) {
    printf("%.2f\n", fmod(-17.5, 4.0));
    return 0;
}

Output

-1.50
Do not use zero as the second argument; the operation is outside the function's valid domain.




plus2net.com






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer