lround, lroundf, lroundl, llround, llroundf, llroundl
부동 소수점 값을 가장 가까운 정수로 반올림합니다.
long lround(
double x
);
long lround(
float x
); // C++ only
long lround(
long double x
); // C++ only
long lroundf(
float x
);
long lroundl(
long double x
);
long long llround(
double x
);
long long llround(
float x
); // C++ only
long long llround(
long double x
); // C++ only
long long llroundf(
float x
);
long long llroundl(
long double x
);
매개 변수
- x
반올림할 부동 소수점 지수 값입니다.
반환 값
lround 및 llround 함수는 가장 가까운 long 또는 long long 정수를 x에 반환합니다. 중간 값은 부동 소수점 반올림 모드의 설정에 상관없이 0 이상의 정수 값으로 표시됩니다. 반환되는 오류가 없습니다.
입력 |
SEH 예외 |
Matherr 예외 |
---|---|---|
± QNAN, IND |
없음 |
_DOMAIN |
설명
C++가 오버로딩을 허용하기 때문에 float와 long double값을 사용하고 반환하는 lround 또는 llround의 오버로드를 호출할 수 있습니다. C 프로그램에서 lround 및 llround는 항상 double을 사용하고 반환합니다.
요구 사항
루틴 |
필수 헤더 |
---|---|
lround, lroundf, lroundl, llround, llroundf, llroundl |
<math.h> |
호환성에 대한 자세한 내용은 호환성을 참조하십시오.
예제
// crt_lround.c
// Build with: cl /W3 /Tc crt_lround.c
// This example displays the rounded results of
// the floating-point values 2.499999, -2.499999,
// 2.8, -2.8, 3.5 and -3.5.
#include <math.h>
#include <stdio.h>
int main( void )
{
double x = 2.499999;
float y = 2.8f;
long double z = 3.5;
printf("lround(%f) is %d\n", x, lround(x));
printf("lround(%f) is %d\n", -x, lround(-x));
printf("lroundf(%f) is %d\n", y, lroundf(y));
printf("lroundf(%f) is %d\n", -y, lroundf(-y));
printf("lroundl(%Lf) is %d\n", z, lroundl(z));
printf("lroundl(%Lf) is %d\n", -z, lroundl(-z));
}