How to not show unnecessary zeros when given integers but still have float answers when needed
生活随笔
收集整理的這篇文章主要介紹了
How to not show unnecessary zeros when given integers but still have float answers when needed
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
? ??NSString *str = [NSString stringWithFormat:@"%g",12.10];
? ? NSLog(@"str = %@",str);
輸出:
str = 12.1
http://stackoverflow.com/questions/19667918/how-to-not-show-unnecessary-zeros-when-given-integers-but-still-have-float-answe
http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html
版權聲明:本文為博主原創文章,未經博主允許不得轉載。
轉載于:https://www.cnblogs.com/zsw-1993/p/4879410.html
總結
以上是生活随笔為你收集整理的How to not show unnecessary zeros when given integers but still have float answers when needed的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [转]Android 代码自动提示功能
- 下一篇: sprytabbedpanels.js库