• 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
NSEqualRects returns wrong answer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSEqualRects returns wrong answer


  • Subject: NSEqualRects returns wrong answer
  • From: Michael Link <email@hidden>
  • Date: Wed, 5 Apr 2006 16:01:54 -0500

I've run into a case where I have code that calls NSEqualRects() with apparently identical NSRects (as reported by gdb) but it still returns NO. Funny thing is that it works when optimization is turned off (as is per default in debug build settings), but when I turn on - Os it doesn't seem to compare correctly. Even more interesting is when I put a call to NSLog before the comparison it seems to work correctly again with optimization turned on. Might there be some optimization setting that is doing something "efficient" with the floats so they might not be equating to an integer perfectly? This is assuming that NSEqualRects uses == comparison on the floats. What is the best way to compare 2 floats?


// NSLog(@"%@ %@", NSStringFromRect([[self contentView] frame]), NSStringFromRect(__contentFrame));

if (NSEqualRects([[self contentView] frame], __contentFrame) == NO) {
[[self contentView] setFrame:__contentFrame];
}


--
Michael

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSEqualRects returns wrong answer
      • From: "John C. Randolph" <email@hidden>
    • Re: NSEqualRects returns wrong answer
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: custom view for NSTabViewItem
  • Next by Date: Re: NSEqualRects returns wrong answer
  • Previous by thread: we are hiring mac programmers
  • Next by thread: Re: NSEqualRects returns wrong answer
  • Index(es):
    • Date
    • Thread