views:

33

answers:

1

So when I convert a double to a string using something like this:

double number = 1.1;
text = [[NSString alloc] initWithFormat:@"%f", number];

The variable text ends up printing something like this: 1.100000. I realize that this is because of the way the computer stores the value however I need an easy way to remove those extra zeros and, if need be, the decimal as well if the number turns out to an integer.

Thanks!

A: 

Try to look at NSNumber and NSNumberFormatter with it's usesSignificantDigits property. It is probably what you are looking for.

beefon
Hmm seems like what I want, but I can't get this to work. I'm a bit of a noob at Objective-C. Anyway I can a bit of example code?
Tyler Johnson