6.11.153 remquol Function

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

Include

<math.h>

Prototype

long double remainder(long double x, long 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)
{
  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 with quotient 2