Formating a number in a string
Formating a number in a string
- Subject: Formating a number in a string
- From: Joe Lertola <email@hidden>
- Date: Sun, 14 Mar 2004 09:23:56 -0500
Hi all,
I am new to cocoa and C programming in general, so I hope you will
excuse me if I ask an obvious question. I have been puttering around
the help system for over an hour without finding the answer to this.
I want to add a floating point number to string as in this example
below:
float sec;
NSString *degreeString;
sec = 123.44;
degreeString = [NSString stringWithFormat: @"my number is %f", sec];
When I run this I get a string like this:
"my number is 123.440002"
How can I limit the number that is inserted into the string to two
decimal places?
Thanks for any help,
-Joe Lertola
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.