绵阳网站制作,外贸商业网站建设,山西网站建设报价单,一般的网站需要多大的空间目录
一.ceil 函数简介二.ceil 函数使用三.猜你喜欢 零基础 C/C 学习路线推荐 : C/C 学习目录 C 语言基础入门 零基础 C/C 学习路线推荐 : C/C 学习目录 C 面向对象 零基础 C/C 学习路线推荐 : C/C 学习目录 C 设计模式 零基础 C/C 学习路线推荐 :…目录
一.ceil 函数简介二.ceil 函数使用三.猜你喜欢 零基础 C/C 学习路线推荐 : C/C 学习目录 C 语言基础入门 零基础 C/C 学习路线推荐 : C/C 学习目录 C 面向对象 零基础 C/C 学习路线推荐 : C/C 学习目录 C 设计模式 零基础 C/C 学习路线推荐 : C/C 学习目录 C STL 零基础 C/C 学习路线推荐 : C/C 学习目录 C/C 技术杂谈 零基础 C/C 学习路线推荐 : C/C 学习目录 C/C 常用函数 一.ceil 函数简介
在 C 语言中 ceil 函数用于对浮点数 float 或者 double 或者 longdouble 向上取整也是一个比较常用的函数 语法如下
#include math.h //需要包含头文件extern float ceilf(float); //参数为flot类型
extern double ceil(double); //参数为double类型
extern long double ceill(long double); //参数为long double类型注意ceil 函数的返回是 double 类型并非 int 类型;
二.ceil 函数使用
ceil 函数主要用于对浮点数向上取整示例如下
/******************************************************************************************/
//Author:猿说编程
//Blog(个人博客地址): www.codersrc.com
//File:C/C ceil 函数
//Time:2021/08/26 08:00
//Motto:不积跬步无以至千里不积小流无以成江海程序人生的精彩需要坚持不懈地积累
/******************************************************************************************/#include stdafx.h
#include stdio.h
#include stdlib.h
#include windows.h
#include math.h //需要包含头文件int main()
{printf(ceil(50.2) %f \n, ceil(50.2));printf(ceil(0.2) %f \n, ceil(0.2));printf(ceil(-50.2) %f \n, ceil(-50.2));printf(ceil(-0.2) %f \n, ceil(-0.2));printf(ceil(100.2) %f \n, ceil(100.2));system(pause);return 0;
}
/*
输出
ceil(50.2) 51.000000
ceil(0.2) 1.000000
ceil(-50.2) -50.000000
ceil(-0.2) -0.000000
ceil(100.2) 101.000000
Press any key to continue . . .
*/三.猜你喜欢
C 语言 数组下标越界和内存溢出区别C 语言 使用指针遍历数组C 语言 指针和数组区别C 语言 指针数组和数组指针区别C 语言 野指针C 语言 函数值传递和址传递C 语言 函数不定长参数C 语言 函数指针C 语言 指针函数C 语言 回调函数 callbackC 语言 #pragma onceC 语言 #include 与 #include “” 区别C 语言 const 修饰函数参数C 语言 const 和 define 区别C 语言 #运算符C 语言 ##运算符C 语言 __VA_ARGS__C 语言 ##__VA_ARGS__C 语言 函数不定长参数 ##__VA_ARGS__经典案例C 语言 va_start / va_end / va_arg 自定义 printf 函数C 语言 main 函数C 语言 main 函数参数 main(int argc, char *argv[])C 语言 局部变量C 语言 全局变量C 语言 全局变量和局部变量区别C 语言 staticC 语言 externC/C Unicode 和多字节区别C/C wprintf 输出中文乱码C/C char 和 wchar_t 相互转换
未经允许不得转载猿说编程 » C/C ceil 函数