discuss-gnustep
[Top][All Lists]
Advanced

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

Foundation Framework had a bug on GNUstep?


From: loserism
Subject: Foundation Framework had a bug on GNUstep?
Date: Sun, 5 Nov 2023 22:44:56 +0800 (GMT+08:00)

Hi All. Let's look at the code first:

#import "stdafx.h"

int main(int argc, const char *argv[]) {

NSNumber *myFloat1;

NSNumber *myFloat2;

myFloat2 = [NSNumber numberWithDouble: 3.14];

myFloat2 = [NSNumber numberWithDouble: 2.78];

NSComparisonResult result;

result = [myFloat1 compare: myFloat2];

if (result == NSOrderedSame) // acutal always

NSLog(@"Numbers are equal");

else if (result == NSOrderedAscending)

NSLog(@"Float1 is less than Float2");

else if (result == NSOrderedDescending) // expected! but not

NSLog(@"Float1 is greater than Float2");

return 0;

}

I found that there seems to be a problem with the compare method of NSNumber, in the code above, why is the comparison result of compare always NSOrderedSame,  it should be NSOrderedDescending here isn't it ?


Best regards!


reply via email to

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