Re: Cocoa-dev Digest, Vol 7, Issue 890
Re: Cocoa-dev Digest, Vol 7, Issue 890
- Subject: Re: Cocoa-dev Digest, Vol 7, Issue 890
- From: Chris Tracewell <email@hidden>
- Date: Wed, 8 Sep 2010 11:07:46 -0700
On Sep 8, 2010, at 10:21 AM, email@hidden wrote:
> The message in the 'if' ([theNumOne compare:theNumTwo]) is an invocation of [NSNumber compare:], not [NSDecimalNumber compare:]. It's not absolutely clear what is supposed to happen when the compare parameter is an instance of NSDecimalNumber. Yes, NSDecimalNumber is a subclass of NSNumber, but these are abstract classes. The actual objects are (typically) concrete subclasses of the abstract classes, such as NSCFNumber. It's possible that this muddies the waters enough that the mixed comparison doesn't work as you would expect.
>
> In any case, why not simply do the comparison between 'self' and '[NSDecimalNumber zero]'?
Quincy thanks for the response... I moved to NSDecimalNumber but am still getting strange behavior. I am truly perplexed - the boolean YES is being returned as -256. I think my problem is with how BOOL is being passed, cast, interpreted... I know it is typedef, it's as if though something is getting "lost in translation. Take a look at the three following code fragments to see the strangeness. I should mention that the category this is being called from is in a private linked framework, if that makes any difference.
The following are called by an NSDecimalNumber with a value of 192.2
// ========== WORKS :: returns 0
-(BOOL)isLessThanZero
{
if ([[NSDecimalNumber zero] compare:self] == NSOrderedDescending)
{
return [[NSDecimalNumber zero] compare:self] == NSOrderedDescending;
}
return NO;
}
// ========== DOES NOT WORK :: returns -256
-(BOOL)isLessThanZero
{
if ([[NSDecimalNumber zero] compare:self] == NSOrderedDescending)
{
return YES;
}
return NO;
}
// ========== DOES NOT WORK :: returns -256
-(BOOL)isLessThanZero
{
return [[NSDecimalNumber zero] compare:self] == NSOrderedDescending;
}
Any ideas?_______________________________________________
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