【发布时间】:2012-06-07 15:10:24
【问题描述】:
好的,所以我正在尝试使用 IBAction 将我的值四舍五入到最接近的整数。
So 1.88 -> 2.00 ,
11.40 -> 12.00 ,
111.01 -> 112.00, etc.
-
-(IBAction)roundUp:(id)sender
{
float floatRoundValue=lblTotalRound.text floatValue];
ceilf(floatRoundValue);
NSString *stringRoundValue = [NSString stringWithFormat:@"%1.0f", floatRoundValue];
lblTotalRound.text=stringRoundValue;
}
这就是我得到的。但它仍然向下舍入到 0.5 以下并到最接近的整数
(Ex. 1.19 -> 1 , i need 1.19 -> 2.00).
我已经尝试了 %1.2f,但值根本没有改变。
我做错了什么?
【问题讨论】: