Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to round decimal for 2 decimal places in Objective-C [duplicate]

Tags:

People also ask

How do I restrict float to 2 decimal places?

Call str. format(*args) with "{:. 2f}" as str and a float as *args to limit the float to two decimal places as a string.


Let me know how to round decimal for 2 decimal places in Objective-C.

I would like to do like this. (all of numbers following sentence is float value)

• round

10.118 => 10.12

10.114 => 10.11

• ceil

10.118 => 10.12

• floor

10.114 => 10.11

Thanks for checking my question.