Reading through the C specs I found this function:
double remquo(double x, double y, int *quo);
float remquof(float x, float y, int *quo);
long double remquol(long double x, long double y,
int *quo);
The
remquo
functions compute the same remainder as theremainder
functions. In the object pointed to by quo they store a value whose sign is the sign ofx/y
and whose magnitude is congruent modulo 2^n to the magnitude of the integral quotient ofx/y
, where n is an implementation-defined integer greater than or equal to 3.The
remquo
functions returnx
REMy
. Ify
is zero, the value stored in the object pointed to byquo
is unspecified and whether a domain error occurs or the functions return zero is implementation defined.
I understand what it returns, it returns fmod(x, y)
, but I don't understand the whole quo
part. Is it semantically equal to this?
*quo = (int) x/y;
*quo %= n; /* n implementation defined */
And my last question, for what could this function be useful?