次の方法で共有


remainder, remainderf, remainderl

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at remainder, remainderf, remainderl.

Computes the remainder of the quotient of two floating-point values, rounded to the nearest integral value.

Syntax

double remainder(   
   double numer,  
   double denom  
);  
float remainder(   
   float numer,  
   float denom  
); /* C++ only */  
long double remainder(   
   long double numer,  
   long double denom  
); /* C++ only */  
float remainderf(   
   float numer,  
   float denom  
);  
long double remainderl(   
   long double numer,  
   long double denom  
);  
  

Parameters

numer
The numerator.

denom
The denominator.

Return Value

The floating-point remainder of x / y. If the value of y is 0.0, remainder returns a quiet NaN. For information about the representation of a quiet NaN by the printf family, see printf, _printf_l, wprintf, _wprintf_l.

Remarks

The remainder function calculates the floating-point remainder r of x / y such that x = n * y + r, where n is the integer nearest in value to x / y and n is even whenever | n - x / y | = 1/2. When r = 0, r has the same sign as x.

Because C++ allows overloading, you can call overloads of remainder that take and return float or long double values. In a C program, remainder always takes two doubles and returns a double.

Requirements

Function Required header
remainder, remainderf, remainderl <math.h>

For compatibility information, see Compatibility.

Example

    // crt_remainder.c  
    // This program displays a floating-point remainder.  
    
    #include <math.h>  
    #include <stdio.h>  
    
    int main( void )  
    {  
    double w = -10.0, x = 3.0, z;  
    
    z = remainder(w, x);  
    printf("The remainder of %.2f / %.2f is %f\n", w, x, z);  
    }  
    The remainder of -10.00 / 3.00 is -1.000000  

.NET Framework Equivalent

System::Math::IEEERemainder

See Also

Floating-Point Support
ldiv, lldiv
imaxdiv
fmod, fmodf
remquo, remquof, remquol