Re: number formatting
Re: number formatting
- Subject: Re: number formatting
- From: Greg Titus <email@hidden>
- Date: Sat, 23 Feb 2002 21:26:05 -0800
On Saturday, February 23, 2002, at 01:23 PM, email@hidden wrote:
Lance, have you read what people have been telling you? Floating point
values don't have exact representations inside the machine.
Run this code and watch it in the debugger.
float value = 0.35;
printf("floating point value: %f\n", value);
The value is represented in the machine as 0.34999...
To force it to show up as 0.35 in a text field the text field would
have
to force the precision to 2 places. Then you'd be still complaining
about
the cases where you wanted more or less precision.
I believe what Lance is really arguing for is an infinite-precision
numeric type in Cocoa. Which, I will admit, would be useful for many
applications. :->
Not infinite precision, but if you are looking for a numeric value that
is represented the same way you typed it in, you should probably look at
NSDecimalNumber.
--Greg
_______________________________________________
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.