开发笔记

  • 首页
  • 工具箱
三味线的博客
  1. 首页
  2. C
  3. 正文

C语言除法向上、向下取整

2019-01-25 3936点热度 13人点赞 0条评论

浮点数

//向上
double ceil(double x);
float ceilf(float x);
long double ceill(long double x);

//向下
double floor(double x);
float floorf(float x);
long double floorl(long double x);

整数

//默认向下取整
int a,b,c;
c=a/b;
//向上
int a,b,c;
c=int(ceil((float)a/(float)b));
c=(a+b-1)/b;//正整数取巧方法
标签: C
最后更新:2020-06-06

三味线

不吃咸鱼的喵

点赞
< 上一篇

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

Captcha Code

COPYRIGHT © 2022 voidcat.cn. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

蜀ICP备18010095号-1