Calculates x
REM y
as a double precision
value.
Include
<math.h>
Prototype
long double remainder(long double x, long double y, int *
quo);
Arguments
x
y
quo
int
object that can hold the
quotientReturn Value
Returns the same remainder as remainder function, being x −
ny
, where n
is the nearest integer to the exact value of
x/y
. In the object pointed to by quo
is stored a
quotient with the same sign as x/y
, and whose magnitude is congruent
modulo 2m to the magnitude of the integral quotient of x/y
, where m is
an implementation-defined integer greater than or equal to 3. The rounding mode is
ignored.
Remarks
If the remainder is 0, its sign shall be the same as that of
x
.
Example
#include <math.h>
#include <stdio.h>
int main(void)
{
long double x, y, z;
int q;
x = 7.0;
y = 3.0;
z = remquol(x, y, &q);
printf("%Lf REM %Lf is %Lf with quotient %d\n", x, y, z, q);
}
Example Output
7.000000 REM 3.000000 is 1.000000