F.9.6.1 The ceil functions

1

  • ceil((+-)0) returns (+-)0.

  • ceil((+-)(inf)) returns (+-)(inf).

2

The double version of ceil behaves as though implemented by

#include <math.h>
#include <fenv.h>
#pragma STDC FENV_ACCESS ON
double ceil(double x)
{
     double result;
     int save_round = fegetround();
     fesetround(FE_UPWARD);
     result = rint(x); // or nearbyint instead of rint
     fesetround(save_round);
     return result;
}