Try this out:

#define CEILING_POS(X) ((X-(int)(X)) > 0 ? (int)(X+1) : (int)(X))
#define CEILING_NEG(X) (int)(X)
#define CEILING(X) ( ((X) > 0) ? CEILING_POS(X) : CEILING_NEG(X) )

Check out the link for comments, proof and discussion: http://www.linuxquestions.org/questions/programming-9/ceiling-function-c-programming-637404/

Thanks to Vilhelm Gray and carveone for pointing out that the linked definition of CEILING_NEG(X) is incorrect.

Answer from nintendo on Stack Overflow
🌐
W3Schools
w3schools.com › c › ref_math_ceil.php
C Math ceil() Function
C Examples C Real-Life Examples ... printf("%f", ceil(-5.9)); Try it Yourself » · The ceil() function rounds a number UP to the nearest integer....
🌐
TutorialsPoint
tutorialspoint.com › c_standard_library › c_function_ceil.htm
C library - ceil() function
The C library ceil() function of type double accept the single argument(x) that returns the smallest integer value greater than or equal to, by the given value. This method rounded up the nearest integer.
🌐
Programiz
programiz.com › c-programming › library-function › math.h › ceil
C ceil() - C Standard Library
The ceil() function computes the nearest integer greater than the argument passed.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › c-ceil-function
C ceil() Function - GeeksforGeeks
July 7, 2024 - C ceil() is a built-in library function that computes the smallest integer value greater than or equal to the given floating-point number.
🌐
Cppreference
en.cppreference.com › w › c › numeric › math › ceil
ceil, ceilf, ceill - cppreference.com
May 23, 2024 - Common mathematical functions · [edit] 1-3) Computes the smallest integer value not less than arg. 4) Type-generic macro: If arg has type long double, ceill is called. Otherwise, if arg has integer type or the type double, ceil is called. Otherwise, ceilf is called.
🌐
TechOnTheNet
techonthenet.com › c_language › standard_library_functions › math_h › ceil.php
C Language: ceil function (Ceiling)
In the C Programming Language, the ceil function returns the smallest integer that is greater than or equal to x (ie: rounds up the nearest integer).
🌐
Microsoft Learn
learn.microsoft.com › en-us › cpp › c-runtime-library › reference › ceil-ceilf-ceill
ceil, ceilf, ceill | Microsoft Learn
July 9, 2025 - double ceil( double x ); float ... C11 or later ... The ceil functions return a floating-point value that represents the smallest integer that is greater than or equal to x....
Find elsewhere
🌐
The Open Group
pubs.opengroup.org › onlinepubs › 009695199 › functions › ceil.html
ceil
This volume of IEEE Std 1003.1-2001 defers to the ISO C standard. These functions shall compute the smallest integral value not less than x.
🌐
Scaler
scaler.com › topics › ceil-function-in-c
Ceil Function in C - Scaler Topics
April 20, 2022 - The ceil() function in C is declared in the math.h header file is used to find a nearest integral value that is not less than the given number(provided as a parameter to the function).
🌐
Cplusplus
cplusplus.com › reference › cmath › ceil
Ceil
double ceil (double x); float ceil (float x);long double ceil (long double x); double ceil (T x); // additional overloads for integral types ... Rounds x upward, returning the smallest integral value that is not less than x. Header <tgmath.h> provides a type-generic macro version of this function.
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › ceil function in c
Ceil() Function in C: Syntax, Usage & Examples
April 23, 2025 - Here’s a concise answer. The ceil() function in C is a mathematical function used to round a floating-point number up to the nearest integer that is greater than or equal to the given value.
🌐
Fresh2Refresh
fresh2refresh.com › home › c programming tutorial › c – arithmetic functions › c – ceil() function
C ceil() function | C Arithmetic functions | Fresh2Refresh
September 23, 2020 - C ceil() function:ceil( ) function in C returns nearest integer value which is greater than or equal to the argument passed to this function.
🌐
Tutorial Gateway
tutorialgateway.org › c-ceil-function
C ceil Function
April 2, 2025 - The C ceil function is one of the Math Functions that returns the smallest integer value, greater than or equal to a given number or a specified expression.
🌐
Quora
quora.com › What-is-the-use-of-ceil-in-C-with-examples
What is the use of ceil in C, with examples? - Quora
Answer (1 of 5): C Language: ceil function (Ceiling) In the C Programming Language, the ceil function returns the smallest integer that is greater than or equal to x (ie: rounds up the nearest integer).
🌐
W3Resource
w3resource.com › c-programming › math › c-ceil.php
C ceil() function
December 24, 2022 - C ceil() function (math.h): The ceil() function is used to compute the smallest integer that is greater than or equal to x.
🌐
O'Reilly
oreilly.com › library › view › c-in-a › 0596006977 › re31.html
ceil - C in a Nutshell [Book]
December 16, 2005 - However, the function does not have an integer type; it returns an integer value, but with a floating-point type. /* Amount due = unit price * count * VAT, rounded up to the next cent */ div_t total = { 0, 0 }; int count = 17; int price = 9999; // 9999 cents is $99.99 double vat_rate = 0.055; // Value-added tax of 5.5% total = div( (int)ceil( (count * price) * (1 + vat_rate)), 100); printf("Total due: $%d.-\n", total.quot, total.rem);
Authors   Peter PrinzTony Crawford
Published   2005
Pages   618
🌐
Codelessons
codelessons.dev › en › ceil-in-c-cplusplus
ceil in C/C++: rounding up
The ceil function in C and C++ rounds a number up. This article explores how to use it with examples, and even how to implement it. We'll also differentiate between `ceil`, `ceill`, and `ceilf`. There are exercises at the end for reinforcement.