Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

JGoose

macrumors member
Original poster
Feb 12, 2010
41
0
How do I remove the unnecessary zeros after the decimal point when a float is displayed in a textfield?
 
okay, so I have that working now, but how do I get it to display a zero (after the decimal) inputted by the user.

example: user inputs "1.06"

The "0" only shows after the user inputs the "6"
I want it to display the "0" whether or not the user inputs another digit.
 
Read the options for the class robbieduncan linked to. Specifically as related to fraction digits. Specifically something that might "set" the "minimum fraction digits".

-Lee
 
the formatter's "minimum fraction digit" is already set to zero in IB if that's what your talking about.
 
Well, that's not what I want though. I want zeros to appear only if the user inputs them. Simply so that they know that they did and that the computer received their input. Basically what the formatter is doing right now is not displaying a zero until it knows that it is a significant digit.
 
Yes, that's what I am doing. first, I read Kochan's "Programming In Objective-C 2.0" and now I'm reading Hillegass. And in the mean time I figured I'd try to make a calculator from scratch on my own as I learned how to do each thing necessary in a calculator. It has actually really helped get a good grasp of the concepts.

I have been able to finish it but there is still this one thing bothering me. I'm still in chapter 17, but I'll take a look at 26. Thanks, mdeh.

Umm, why not just display the string the user inputs then, and handle it like a double internally?

That is what I was doing, but since it is a calculator, the program displays the result in double format with all the extra zeros, which I also want to avoid.
 
Ok, in that case, why not just leave the string the user inputs UNTIL they actually calculate something, then replace the string with NSNumberFormatter stringFromNumber: version.
 
Ok, in that case, why not just leave the string the user inputs UNTIL they actually calculate something, then replace the string with NSNumberFormatter stringFromNumber: version.

Which means you will have to do your own filtering on input so that you only get numerics and action keys.
 
...... And in the mean time I figured I'd try to make a calculator from scratch on my own as I learned how to do each thing necessary in a calculator. It has actually really helped get a good grasp of the concepts.

Agreed, 100%. It seems pretty pointless rushing through Hillegass and not really achieving anything other than having rushed through Hillegass at the end of the book. This forum is a wonderful setting to get answers...but I must stress ...**not homework** answered. You are expected to at least show that you are trying to understand.
BTW...I went back and redid the Chap 14 challenge and answered your questions...not sure if you saw that.
 
Yes, I did, thanks.

Ok, in that case, why not just leave the string the user inputs UNTIL they actually calculate something, then replace the string with NSNumberFormatter stringFromNumber: version.

Sounds like a good idea, I'll try that.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.