I\'m using the following piece of Objective-C code to format a NSNumber, and it works fine most of the time, but it doesn\'t quite do what I want when the NSNumber object ho
Your format string should have a "0
" for each decimal place you want to always exist.
[formatter setFormat:@"###.00"];
for "55.23" and ".23" and ".20"
[formatter setFormat:@"##0.00"];
for "55.23" and "0.23" and "0.20"
See Number Format String Syntax (Mac OS X Versions 10.0 to 10.3)
Or you can use a 10.4 formatter with - setMinimumFractionDigits: and - setMaximumFractionDigits: with both set to 2.