Implement ceil() in C
问题 I want to implement my own ceil() in C . Searched through the libraries for source code & found here, but it seems pretty difficult to understand. I want clean & elegant code. I also searched on SO, found some answer here. None of the answer seems to be correct. One of the answer is: #define CEILING_POS(X) ((X-(int)(X)) > 0 ? (int)(X+1) : (int)(X)) #define CEILING_NEG(X) ((X-(int)(X)) < 0 ? (int)(X-1) : (int)(X)) #define CEILING(X) ( ((X) > 0) ? CEILING_POS(X) : CEILING_NEG(X) ) AFAIK, the