Home C&C++函数库 c++ 语法 程序源码 Linux C库

ceil

函数  <cmath> <ctgmath>

C90 double ceil (double x);
C99 double ceil (double x);
float ceilf (float x);
long double ceill (long double x);
C++98 double ceil (double x);
float ceil (float x);
long double ceil (long double x);
C++11 double ceil (double x);
float ceil (float x);
long double ceil (long double x);
double ceil (T x);        // additional overloads for integral types

上舍入
向上舍入x,返回不小于x的最小整数值。
C99 头文件<tgmath.h> 提供了该函数的类型泛型宏版本。
C++11 这个头文件(<cmath>) 为整型提供了额外的重载:这些重载在计算之前将x转换为double (在T是任何整型时定义)。

☲  参数


x
要上舍入的值

☉  返回值



不小于x的最小整数值(浮点值)。

☣  示例



/* ceil example */
#include <stdio.h>      /* printf */
#include <math.h>       /* ceil */

int main ()
{
  printf ( "ceil of 2.3 is %.1f\n", ceil(2.3) );
  printf ( "ceil of 3.8 is %.1f\n", ceil(3.8) );
  printf ( "ceil of -2.3 is %.1f\n", ceil(-2.3) );
  printf ( "ceil of -3.8 is %.1f\n", ceil(-3.8) );
  return 0;
}

输出:
ceil of 2.3 is 3.0
ceil of 3.8 is 4.0
ceil of -2.3 is -2.0
ceil of -3.8 is -3.0

🍄  另请参阅



fabs 绝对值(function )
floor 向下舍入(function )
modf 分成小数部分和整数部分 (function )

联系我们 免责声明 关于CandCplus 网站地图