반응형

소수점 이하를 올림하거나 내림하는 함수 입니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
#include <math.h>
 
int main(void)
{
    double x = 1.5;
    printf("ceil(%f) =%f\n", x, ceil(x));
    printf("floor(%f) =%f\n", x, floor(x));
    return 0;
}
 
//결과값
// ceil(1.5) = 2
// floor(1.5) = 1
cs


ceil은 올림 함수 이고

floor은 내림 함수입니다.


유용하게 사용할 수 있습니다.


반응형

+ Recent posts