ceil(value):求大于小數(shù)value的最小整數(shù)。
floor(value):求小于小數(shù)value的最大整數(shù)炉爆。
round(value):小數(shù)value的四舍五入取整。
示例(一):
CGFloat width = 70.15;
[self logCeilFoorRoundWithValue:width];
打印:
ceil(a) = 71.000000
floor(a) = 70.000000
round(a) = 70.000000
示例(二):
width = 70.77;
[self logCeilFoorRoundWithValue:width];
打臃沂住:
ceil(a) = 71.000000
floor(a) = 70.000000
round(a) = 71.000000
- (void)logCeilFoorRoundWithValue:(CGFloat)value {
NSLog(@"ceil(a) = %f", ceil(value));
NSLog(@"floor(a) = %f", floor(value));
NSLog(@"round(a) = %f", round(value));
}