なぜresult NSOrderedDescendingですか?
NSDecimalNumber *decimal = [[NSDecimalNumber alloc] initWithString:@"2.6"];
NSComparisonResult result = [decimal compare:[NSNumber numberWithFloat:2.6]];
なぜresult NSOrderedDescendingですか?
NSDecimalNumber *decimal = [[NSDecimalNumber alloc] initWithString:@"2.6"];
NSComparisonResult result = [decimal compare:[NSNumber numberWithFloat:2.6]];
2.6浮動小数点数として正確に表すことはできませんが、NSDecimalこの値を正確に表すことはできます (これが、最初に NSDecimals が必要な理由です)。
IEEE 754 Calculatorによると、2.6は に変換され2.5999999046325684、これは より小さいため2.6、 と比較されNSOrderedDescendingます。