Re: NSLog with %f and comparisons using ==
Re: NSLog with %f and comparisons using ==
- Subject: Re: NSLog with %f and comparisons using ==
- From: Ken Thomases <email@hidden>
- Date: Sun, 12 Apr 2009 17:03:54 -0500
Chiming in late-ish...
On Apr 11, 2009, at 12:26 PM, James Maxwell wrote:
oooh, damn... I was afraid someone was going to say that. I just
hoped there might be some way to force a float to conform to what
NSLog %f prints... That seems like it might be a useful function -
something like pround(aFloat), for "print-round", to force any float
number to round as the printf %f would round it. Anyway, that's
obviously not available.
It's not available because it's not possible. The print-formatting
functions are rounding in decimal but floats are represented in
binary. There are many values that seem simple to express in decimal
but which are impossible to represent precisely in finite-precision
binary.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden