remainder, remainderf, remainderl

두 부동 소수점 값 몫의 나머지를 가장 가까운 적분 값으로 반올림하여 계산합니다.

구문

double remainder( double x, double y );
float remainderf( float x, float y );
long double remainderl( long double x, long double y );
#define remainder(X, Y) // Requires C11 or higher

float remainder( float x, float y ); /* C++ only */
long double remainder( long double x, long double y ); /* C++ only */

매개 변수

x
분자입니다.

y
분모입니다.

반환 값

x / y의 부동 소수점 나머지입니다. y의 값이 0.0인 경우 remainder는 자동 NaN을 반환합니다. 가족에 의한 printf 조용한 NaN의 표현에 대한 자세한 내용은printf , ,_printf_lwprintf_wprintf_l .

설명

함수는 remainder 부동 소수점 re기본der rx = n * y + rx / y 계산합니다. 즉, 값 nx / y 에서 가장 가까운 정수이며 n 언제|n - x / y| = 1/2든 계산됩니다. 때 r = 0는 . r 와 같은 기호가 있습니다 x.

C++에서는 오버로드를 허용하므로 remainder 또는 float 값을 사용 및 반환하는 long double의 오버로드를 호출할 수 있습니다. C 프로그램에서 tgmath.h 매크로를 사용하여 <이 함수 remainder 를 호출하지 않는 한 항상 두 개의 double 인수를 가져와서 반환합니다double.>

tgmath.h>remainder() 매크로를 <사용하는 경우 인수 형식에 따라 선택한 함수 버전이 결정됩니다. 자세한 내용은 형식 제네릭 수학을 참조하세요.

기본적으로 이 함수의 전역 상태는 애플리케이션으로 범위가 지정됩니다. 이 동작을 변경하려면 CRT의 전역 상태를 참조하세요.

요구 사항

함수 필수 헤더(C) 필수 헤더(C++)
remainder, remainderf, remainderl <math.h> <cmath> 또는 <math.h>
remainder 매크로 <tgmath.h>

호환성에 대한 자세한 내용은 호환성을 참조하세요.

예시

// 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

참고 항목

수학 및 부동 소수점 지원
ldiv, lldiv
imaxdiv
fmod, fmodf
remquo, remquof, remquol