How to format a double Value upto 2 decimal places in iPhone

前端 未结 3 1191
长情又很酷
长情又很酷 2020-12-20 04:20

I am extracting double data from sqlite3 database. But I want to display it only upto two decimal places. So how to truncate it.

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-20 04:47

    Use sprintf formatting with NSString: [NSString stringWithFormat: @"%.2f", myValue];

提交回复
热议问题