반올림 함수
1
2
3
4
5
6
7
8
9
10
11
/* at : 반올림할 소수점 자리 */
double round(const double& a , const int& at)
{
double ret = a;
ret*= pow(10, (at - 1));
ret = (ret > 0) ? floor(ret + 0.5) : ceil(ret - 0.5);
ret*= pow(10, -(at - 1));
return ret;
}