fmod

Computes the floating-point remainder of x / y

Local Servers:nonblocking
Remote Servers:N/A
Classification:ANSI
Service:Mathematical Computation

Syntax

  #include <math.h>  
   
  double fmod  (  
     double   x,  
     double   y);
  

Parameters

x and y
(IN) Specifies the arguments for which the floating-point remainder is to be computed.

Return Values

The fmod function returns the value x - ( i * y), for some integer i such that, if y is nonzero, the result has the same sign as x and a magnitude less than the magnitude of y. If the value of y is zero, then the value returned is zero.

Remarks

The fmod function computes the floating-point remainder of x / y, even if the quotient x / y is not representable.

See Also

ceil, fabs, floor

Example

  #include <math.h>  
  #include <stdio.h>  
   
  main ()  
  {  
     printf ("%f\n", fmod (4.5,  2.0) );  
     printf ("%f\n", fmod (-4.5,  2.0) );  
     printf ("%f\n", fmod (4.5, -2.0) );  
     printf ("%f\n", fmod (-4.5, -2.0) );  
  }
  

produces the following:

     0.500000  
    -0.500000  
     0.500000  
    -0.500000