'C++' std::ceil, std::ceilf, std::ceill

토스트·2025년 1월 28일

'C++' std::cmath

목록 보기
4/10

ceil

tmplate<class Integer>
double ceil(Integer num); // constexpr since C++23

~ C++23

float ceil(float num);

double ceil(double num);

long double ceil(long double num);

C++23 ~

constexpr /*floating-point-type*/ ceil(/*floating-point-type*/ num);

: 가장 가까운 정수로 올림한 값을 반환합니다.

ceilf

float ceilf(float num); // constexpr since C++23

: float 타입에 대해 가장 가까운 정수로 올림한 값을 반환합니다.

ceill

long double ceill(long double num); // constexpr since C++23

: long double 타입에 대해 가장 가까운 정수로 올림한 값을 반환합니다.

  • num : 천장을 구하려는 값

<example>

#include <iostream>
#include <cmath>

using namespace std;

int main() {
	cout << ceil(5.3) << endl;

	cout << ceil(4) << endl;

	cout << ceilf(2.714f);

	return 0;
}

결과값

0개의 댓글