self.orderCost.text = [NSStringstringWithFormat:@"%.1f元",self.order.cost.floatValue]; %.1f 表示小数点一位,%.2f 表示小数点2位,依次类推 格式定义The format specifiers supported by the NSString formatting methods and CFString formatting functions follow the IEEE printf…
@"0.01" 转换成float时, 经常会变成 0.009999799 这种形式, 因为float类型无法精准保存, 系统会选一个接近的值来代替. 而double类型则可以有更好的精度. http://stackoverflow.com/questions/9328260/converting-nsstring-to-float-adds-in-decimal-places Your issue seems to be that you don't understand how f…