Reading the answer of @anton in this link I tried to see if really remainder(x, y)
is exactly x-(round(x/y)*y)
.
Running the code for the value of x=5.
and y=2.
. I got:
printf("the value of remainder is %f\n",remainder(x, y));
printf("the value of remainder is %f\n",x-(round(x/y)*y));
the value of remainder is 1.000000
the value of remainder is -1.000000
From wikipedia :
Floating point remainder. This is not like a normal modulo operation, it can be negative for two positive numbers. It returns the exact value of x–(round(x/y)·y).
Is the explanation of Anton wrong, or am I missing something ?