Re: Crazy floats
Re: Crazy floats
- Subject: Re: Crazy floats
- From: Ricky Sharp <email@hidden>
- Date: Fri, 23 Jul 2004 09:41:15 -0500
On Friday, July 23, 2004, at 09:30AM, Lorenzo <email@hidden> wrote:
>
Thank you. How can I truncate the value 0.6970001 to 0.697 ?
>
I mean 3 decimals.
Are you doing this for display purposes only? If so, in standard C:
char numberBuffer [kSomeBufferSize];
memset (numberBuffer, 0, kSomeBufferSize);
sprintf (numberBuffer, "%.3f", someFloatValue);
Or in Obj-C to create an NSString:
NSString* numberString = [NSString stringWithFormat:@"%.3f", someFloatValue];
Rick Sharp
Instant Interactive(tm)
_______________________________________________
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.