6.11.151 remquo Function

Calculates x REM y as a double precision floating-point value.

Include

<math.h>

Prototype

double remquo(double x, double y, int * quo);

Arguments

x
a double precision floating-point value
y
a double precision floating-point value
quo
a pointer to an int object that can hold the quotient

Return 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

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

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

int main(void)
{
  double x, y, z;
  int q;

  x = 7.0;
  y = 3.0;
  z = remquo(x, y, &q);
  printf("%f REM %f is %f with quotient %d\n", x, y, z, q);
}

Example Output

7.000000 REM 3.000000 is 1.000000 with quotient 2