• 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
NSLog with %f and comparisons using ==
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSLog with %f and comparisons using ==


  • Subject: NSLog with %f and comparisons using ==
  • From: James Maxwell <email@hidden>
  • Date: Sat, 11 Apr 2009 09:46:32 -0700

I've got a strange problem.
I have a list of float constants that I need to compare to the result of a new calculation.


I derived the constants by performing the calculation, and printing using NSLog with %f, then just writing down the results in my array of constants.
So, the result of the calculation used to derive the float constants was run through NSLog, using the %f token.


Now, when I run the calculation "live" and try to compare to my stored constants, I'm not getting matches. I'm assuming this is because the result of the calculation *isn't* actually what I stored in my constants, since the constants were rounded during the NSLog. So, how do I make sure my "live" calculation returns a value that will be rounded in the same way as an NSLog(@"%f", aFloat)?

That's a confusing question, I know... I hope it makes sense to somebody.

J.

_______________________________________________

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


  • Follow-Ups:
    • Re: NSLog with %f and comparisons using ==
      • From: Michael Ash <email@hidden>
  • Prev by Date: Re: NSTextFieldCell text color issue in NSTableView with source list highlighting
  • Next by Date: Re: Rendering OpenGL in timed loop (CoreVideo).
  • Previous by thread: Re: NSTextFieldCell text color issue in NSTableView with source list highlighting
  • Next by thread: Re: NSLog with %f and comparisons using ==
  • Index(es):
    • Date
    • Thread