【发布时间】:2015-05-26 01:35:45
【问题描述】:
我有以下代码:
float temp;
temp = 2.0f;
- (IBAction)MinusTouched:(id)sender {
if (temp>0.0) {
temp=temp-0.1f;
[TempValue setText:[NSString stringWithFormat:@"%.1f",temp]];
}
}
当我通过单击按钮执行操作时,温度值会减小。但它在 0.1 之后打印 -0.0 ,我该如何修剪负号? 我的意思是我想要一个绝对浮点值。
【问题讨论】:
标签: ios objective-c iphone ipad cocoa-touch