6.11.148 remainder Function

Calculates x REM y as a double precision value.

Include

<math.h>

Prototype

double remainder(double x, double y);

Arguments

x
a double precision floating-point value
y
a double precision floating-point value

Return Value

Returns the remainder x REM y, being x − ny, where n is the nearest integer to the exact value of x/y when y is not 0. The rounding mode is ignored. 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;

  x = 7.0;
  y = 3.0;
  z = remainder(x, y);
  printf("%f REM %f is %f\n", x, y, z);
}

Example Output

7.000000 REM 3.000000 is 1.000000