Subtract the integer from the decimal. If the difference is zero, then the decimal is an integer.
// testVal is NSDecimalNumber NSString *test = [testVal stringValue]; int intVal = [test intValue]; double doubleVal = [test doubleValue]; if(doubleVal-intVal == 0){ NSLog(@"Whole number!"); }
Or, get an integer and compare with the original value:
if(intVal == doubleVal){ NSLog(@"Whole number!"); }
source share