NSLog(@"%02ld",2); NSLog(@"%0.2f",0.2656); NSLog(@"%0.2f",0.2646); 注意的是%0.2f 是会对数字进行一个四舍五入 2016-06-20 14:57:28.506 App[4010:98217] 02 2016-06-20 14:57:28.507 App[4010:98217] 0.27 2016-06-20 14:57:28.507 App[4010:98217] 0.26
NSLog(@"%02ld",2); NSLog(@"%0.2f",0.2656); NSLog(@"%0.2f",0.2646); 注意的是%0.2f 是会对数字进行一个四舍五入 2016-06-20 14:57:28.506 App[4010:98217] 02 2016-06-20 14:57:28.507 App[4010:98217] 0.27 2016-06-20 14:57:28.507 App[4010:98217] 0.26