NSEqualRects returns wrong answer
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