ceil()

Returns the next whole number that is greater than or equal to the argument.

Syntax

std::ceil(n);

Argument must be a double/float/long double, and the return value will be same type.

Example

Use ceil() function to round up the double 12.3456:

#include <iostream>
#include <cmath>
int main() {
double n = 12.3456;
double result;
result = std::ceil(n);
std::cout << "The result is " << result << "!\n";
// Output: The result is 13!
}

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn C++ on Codecademy

Contributors