gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNumber Bug I can't fix


From: Marcus Müller
Subject: Re: NSNumber Bug I can't fix
Date: Thu, 17 Feb 2011 17:01:47 +0100


As you can see above, asking an NSIntNumber instance for its doubleValue works properly, however, it fails at NSNumber.m:165. I don't know the reason, but I also don't understand the implications of the macros used. Can somebody elaborate? Please note that I'm on a 64-bit (amd64) system.

Thinking about it, I guess my hint was pretty bogus. I believe the real problem here is the COMPARE macro which compares a double with a NaN, which simply won't work:

#define COMPARE(value, other) \
if (value < other)\
  {\
    return NSOrderedAscending;\
  }\
if (value > other)\
  {\
    return NSOrderedDescending;\
  }\
return NSOrderedSame;

If either is a nan, this will return NSOrderedSame which is, well, not incorrect. However, in the context of NSNumber.m:165 it returns a wrong result.

This raises the question, what should be done to - (NSComparisonResult) compare: (NSNumber*)aNumber?
Comparing a NaN with another number is undefined and might lead to NSOrderedSame, but it should never lead to [2 isEqualToNumber:NaN] == YES. I'm not sure how to fix this properly, but not returning NSOrderedSame in this case would certainly help.

Cheers,


  Marcus


-- 

Marcus Mueller  .  .  .  crack-admin/coder ;-)

Mulle kybernetiK  .  http://www.mulle-kybernetik.com

Current projects: http://www.mulle-kybernetik.com/znek/



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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]