#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; } |