ceil()
Published Jul 16, 2021Updated Dec 21, 2022
Contribute to Docs
The ceil()
function 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!}
All contributors
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.