I am trying to format some floats as follows:
1.1500 would be displayed as “$ 1.15”
1.1000 would be displayed as “$ 1.10”
1.0000 would be displayed as “$ 1.00”
1.4710 would be displayed as “$ 1.471”
1.4711 would be displayed as “$ 1.4711”
I tried with
NSString *answer = [NSString stringWithFormat:@"$ %.2f",myvalue];
I have figure out this. you can do this as per below implementation.
Please take a look at below demo code…
Thanks,
MinuMaster