remquof Function

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

Include

<math.h>

Prototype

float requof(float x, float y, int * quo);

Arguments

x
a single precision floating-point value
y
a single 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)
{
  float x, y, z;
  int q;

  x = 7.0;
  y = 3.0;
  z = remquof(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