ios - Show the float value in formatted string two digits after decimal in iPhone -


i have float number in insert comma after thousands value works fine

nsnumberformatter *formatter = [nsnumberformatter new]; [formatter setnumberstyle:nsnumberformatterdecimalstyle]; // line important!  nsstring *formatted = [formatter stringfromnumber:[nsnumber numberwithfloat:appdelegate.c_wnd_clininf_average_default]]; 

but shows 1,947 want show 1,947.00 idea how formate this.

thanks

have tried using -setmaximumfractiondigits nsnumberformatter?

so, try like:

[formatter setmaximumfractiondigits:2]; [formatter setminimumfractiondigits:2]; 

this way deal nsnumberformatter , don't need call on nsstring.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -