NSNumberFormatter for rounding up float values

后端 未结 4 663
孤城傲影
孤城傲影 2021-01-07 05:06

I have a CGFloat value which I want to round to 3 digits after the decimal point. How should I do this?

Thanks.

4条回答
  •  不思量自难忘°
    2021-01-07 05:28

    Try formatting the float as "%5.3f" or similar for display purposes

    ...like Zach Langley did in his better answer.

提交回复
热议问题