remainder - C math.h

C examples for math.h:remainder

Type

function

From

<cmath>
<ctgmath>
<math.h>

Description

Returns the floating-point remainder of numer/denom (rounded to nearest):

remainder = numer - rquot * denom 

Where rquot is the result of: numer/ denom, rounded toward the nearest integral value.

Prototype

long double remainderl (long double numer, long double denom);
long double remainder (long double numer, long double denom);
     double remainder  (double numer     , double denom);
      float remainderf (float numer      , float denom);
     double remainder (Type1 numer      , Type2 denom);       

Parameters

Parameter Description
numer Value of the quotient numerator.
denom Value of the quotient denominator.

Return Value

The remainder of dividing the arguments.

Example

Demo Code


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

int main ()//from w w w .j av  a  2s .  c  om
{
  printf ( "%f\n", remainder (5,2) );
  printf ( "%f\n", remainder (5.3,2) );  
  printf ( "%f\n", remainder (18.5,3.2) );
  return 0;
}

Related Tutorials