```
1、四舍五入:要保留的小数点位后面的以为如>=5,则向前进1,反之,舍去
//1️⃣
float testNumber1 = 4.83;
int result = (int)roundf(testNumber);
NSLog(@"roundf(%0.2f) = %d",testNumber,result);
//输出roundf(4.83) = 5;
//2️⃣
float testNumber1 = 4.23;
int result = (int)roundf(testNumber);
NSLog(@"roundf(%0.2f) = %d",testNumber,result);
//输出roundf(4.23) = 4;
```
```
2.进一:要保留的小数位后面一位无论为多少,都向前进1
//1️⃣
float testNumber1 = 4.83;
int result = (int)ceilf(testNumber);
NSLog(@"roundf(%0.2f) = %d",testNumber,result);
//输出roundf(4.83) = 5;
//2️⃣
float testNumber1 = 4.23;
int result = (int)ceilf(testNumber);
NSLog(@"ceilf(%0.2f) = %d",testNumber,result);
//输出rceilf(4.23) = 5;
```
```
3.退位:要保留的小数位后面一位无论为多少,都舍去
//1️⃣
float testNumber1 = 4.83;
int result = (int)floorf(testNumber);
NSLog(@"floorf(%0.2f) = %d",testNumber,result);
//输出floorf(4.83) = 4;
//2️⃣
float testNumber1 = 4.23;
int result = (int)floorf(testNumber);
NSLog(@"floorf(%0.2f) = %d",testNumber,result);
//输出floorf(4.23) = 5;
```