I am building a calculator and have run into a problem with displaying unnecessary 0's (it isn't displaying them and I want it to be).
An example of what it does now is as follows. [Represents Calculator Screen]
[Blank Calculator Screen]
User hits "4"
[4]
User hits "."
[4]
User hits "0"
[4]
User hits "0"
[4]
User hits "5"
[4.005]
Instead, I want to make it do the following:
[Blank Calculator Screen]
User hits "4"
[4]
User hits "."
[4.]
User hits "0"
[4.0]
User hits "0"
[4.00]
User hits "5"
[4.005]
I use a number formatter as shown below...
formatter = [[NSNumberFormatter alloc] init];
formatter.numberStyle = NSNumberFormatterDecimalStyle;
formatter.maximumIntegerDigits = 13;
formatter.minimumFractionDigits = 0;
formatter.maximumFractionDigits = 13;
formatter.maximumSignificantDigits = 13;
formatter.usesGroupingSeparator = YES;
formatter.groupingSeparator = @",";
formatter.decimalSeparator = @".";
formatter.generatesDecimalNumbers = true;
I use the following to call my numbers...
buttonScreen.text = [formatter stringFromNumber:
[NSNumber numberWithDouble:currentNumber]]
Thanks!