Single precision and long double precision floating-point remainder fmodf fmodl
suggest changefmodf and fmodl return the floating-point remainder of x / y, with the same sign as x. If y is zero, a domain error occurs. Inspecting the numeric result is not a portable way to detect it; see Standard Math.
Single Precision:
#include <math.h> /* for fmodf() */
#include <stdio.h> /* for printf() */
int main(void)
{
float x = 10.0;
float y = 5.1;
float modulus = fmodf(x, y);
printf("%.5f\n", modulus);
}
4.90000
Long double precision:
#include <math.h> /* for fmodl() */
#include <stdio.h> /* for printf() */
int main(void)
{
long double x = 10.0;
long double y = 5.1;
long double modulus = fmodl(x, y);
printf("%.5Lf\n", modulus);
}
4.90000
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents