• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSLog with %f and comparisons using ==
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSLog with %f and comparisons using == (From: James Maxwell <email@hidden>)
 >Re: NSLog with %f and comparisons using == (From: Michael Ash <email@hidden>)
 >Re: NSLog with %f and comparisons using == (From: James Maxwell <email@hidden>)

  • Prev by Date: Converting String Representations at Runtime
  • Next by Date: Re: Build Settings for Release: App/Library is bloated
  • Previous by thread: Re: NSLog with %f and comparisons using ==
  • Next by thread: Re: NSLog with %f and comparisons using ==
  • Index(es):
    • Date
    • Thread