Have you tried this?CGFloat val = 37.777779;CGFloat rounded_down = floorf(val * 100) / 100; /* Result: 37.77 */CGFloat nearest = floorf(val * 100 + 0.5) / 100; /* Result: 37.78 */CGFloat rounded_up = ceilf(val * 100) / 100; /* Result: 37.78 */source : Rounding Number to 2 Decimal Places in CComplementing: You just don‘t have control about how the computer will store the float value.So the...
// 设置值 NSNumber *number=[NSNumber numberWithInt:45]; // 取值 NSLog(@"NSNumber %d",[number intValue]); 原文:http://www.cnblogs.com/feiling/p/4721387.html