- 向下取整
1. 强制类型转换
float f = 1.5; int a; a = (int)f;
2. 高斯函数
double floor(double a)
float f =1.5; int a; a = floor(f);
- 向上取整
1. ceil函数
double ceil(double a)
float f =1.5; int a; a = ceil(f);
2. 强制类型转换 + 四舍五入
float f =1.5; int a; a = (int)(f + 0.5);
标签:1.5,int,double,浮点数,float,C语言,取整,ceil From: https://www.cnblogs.com/nonamer/p/17845440.html