The round, ceil and floor functions in iOS are slightly solved

Source: Internet
Author: User

Apple Official Document location: usr/include > MATH.H

externFloatCeilf(float);externDoubleCeil(Double);externLongDoubleCeill(LongDouble);externFloatFloorf(float);externDoubleFloor(Double);extern long double floorlextern float roundf (float); extern double round (double); extern long double roundl (long double) ; 
round 如果参数是小数,则求本身的四舍五入.ceil 如果参数是小数,则求最小的整数但不小于本身.floor 如果参数是小数,则求最大的整数但不大于本身.

Example: How the value is 3.4, then
--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这种形式

Round, ceil, floor functions in iOS are slightly solved

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.