Rounding, top rounding, bottom rounding

Source: Internet
Author: User

    floatTMPFLOATDATA2 =3.7; NSString*TMPSTR2 = [NSString stringWithFormat:@"%.0f", TMPFLOATDATA2]; NSLog (@"tmpStr2 =%@", TMPSTR2);//result is 4    floatTMPFLOATDATA3 =6.5; NSString*TMPSTR3 = [NSString stringWithFormat:@"%.0f", TMPFLOATDATA3]; NSLog (@"tmpStr2 =%@", TMPSTR3);//result is 6

If you use the above mode to make rounding, take up the whole, the result of the next rounding is unreliable, it is best not to use the above method to deal with the number of high-demand places

NSLog (@ "TMPSTR4 =%f", Floorf (TMPFLOATDATA3));//Bottom rounding

NSLog (@ "TMPSTR5 =%f", Ceilf (TMPFLOATDATA3));//Upper rounding

NSLog (@ "TMPSTR6 =%f", ROUNDF (TMPFLOATDATA3));//rounding

#include <math.h> file There are a lot of our usual mathematical functions, such as the next rounding, rounding up rounding, Sin,cos,tan

Rounding, top rounding, bottom rounding

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.