@interface NSDecimalNumber (IsIntegerNumber)
@property (readonly) BOOL isIntegerNumber;
@end
@implementation NSDecimalNumber (IsIntegerNumber)
-(BOOL)isIntegerNumber {
NSDecimalValue value = [self decimalValue];
if (NSDecimalIsNotANumber(&value)) return NO;
NSDecimal rounded;
NSDecimalRound(&rounded, &value, 0, NSRoundPlain);
return NSDecimalCompare(&rounded, &value) == NSOrderedSame;
}
@end
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…