Desc :

실수의 소수점을 버리고

 

floor - 실수보다 작은 수로 출력

ceil - 실수보다 큰 수로 출력

 


Source Code :

#include <iostream>

using namespace std;

int main()
{
	cout << "== 소수점 버리기 ==" << endl;
	cout << "floor(1.1) : " << floor(1.1) << endl;
	cout << "floor(-55.7) : " << floor(-55.7) << endl;	// -55.7 > -56

	cout << "== 소수점 올리기==" << endl;
	cout << "ceil(1.1) : " << ceil(1.1) << endl;
	cout << "ceil(40.5) : " << ceil(40.5) << endl;
	cout << "ceil(-55.7) : " << ceil(-55.7) << endl;	// -55.7 < -55
}

 


Result :

+ Recent posts