当前位置: 移动技术网 > 移动技术>移动开发>IOS > iOS中的round/ceil/floorf函数略解

iOS中的round/ceil/floorf函数略解

2018年10月22日  | 移动技术网移动技术  | 我要评论

ios中的round/ceil/floorf函数略解

extern float ceilf(float);

extern double ceil(double);

extern longdouble ceill(longdouble);

extern float floorf(float);

extern double floor(double);

extern longdouble floorl(longdouble);

extern float roundf(float);

extern double round(double);

extern longdouble roundl(longdouble);

round:如果参数是小数,则求本身的四舍五入。

ceil:如果参数是小数,则求最小的整数但不小于本身.

floor:如果参数是小数,则求最大的整数但不大于本身.

 

example:如何值是3.4的话,则

3.4 -- round 3.000000

-- ceil 4.000000

-- floor 3.00000

cgrectmake(floorf(self.view.bounds.size.width*0.5f - 39.f*0.5f),self.view.bounds.size.height -57, 39, 39)

其中floorf(self.view.bounds.size.width*0.5f-39.f*0.5f)返回值为

140.000000这种形式

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网