On 15/08/2009, at 5:01 PM, Adil Saleem wrote:
But why would it round 863.6 ? I mean there is only 1 digit after
the decimal. It should not have the range problem with a value this
small.
It's got nothing to do with how it is written in decimal - it only
matters what its binary representation is, and that is always 32 bits
(or 64 if double precision or on a 64-bit machine).
Start here, particularly the section starting "Accuracy Problems":
http://en.wikipedia.org/wiki/Floating_point
Note, there is a class called NSDecimalNumber which can help with this
sort of problem, if you can't live with the vagueness of float.
--Graham
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com