언어 자료구조 알고리즘/C11 표준 라이브러리 함수
round, roundf, roundl
언제나휴일
2016. 5. 10. 17:46
반응형
round, roundf, roundl
헤더 파일
[언어 자료구조 알고리즘/C11 표준 라이브러리 함수] - math.h
double round(double x); 반올림, nearbyint와 같음
float roundf(float x); 반올림, nearbyintf와 같음
long double roundl(long double x); 반올림, nearbyintl과 같음
입력 매개 변수 리스트
x 실수
반환 값
x 반올림
사용 예
//C언어 표준 라이브러리 함수 가이드
//double round(double x); 반올림, nearbyint와 같음
//float roundf(float x); 반올림, nearbyintf와 같음
//long double roundl(long double x); 반올림, nearbyintl과 같음
#include <math.h>
#include <stdio.h>
int main(void)
{
printf("%f\n", round(1.4));
printf("%f\n", round(1.5));
printf("%f\n", round(2.1));
printf("%f\n", round(2.9));
return 0;
}
출력
1.000000
2.000000
2.000000
3.000000
사용한 함수
반응형