- (BOOL)judgeDivisibleWithFirstNumber:(CGFloat)firstNumber andSecondNumber:(CGFloat)secondNumber {
// 默认记录为整除
BOOLisDivisible =YES;
if(secondNumber == 0) {
returnNO;
}
CGFloatresult = firstNumber / secondNumber;
NSString * resultStr = [NSString stringWithFormat:@"%f", result];
NSRangerange = [resultStrrangeOfString:@"."];
NSString* subStr = [resultStrsubstringFromIndex:range.location+ 1];
for(NSIntegerindex = 0; index < subStr.length; index ++) {
unicharch = [subStrcharacterAtIndex:index];
// 后面的字符中只要有一个不为0,就可判定不能整除,跳出循环
if('0' != ch) {
// NSLog(@"不能整除");
isDivisible =NO;
break;
}
}
// NSLog(@"可以整除");
returnisDivisible;
}