+ (NSInteger)getUnits:(NSInteger)targetInt {
NSString *strNum = [NSString stringWithFormat:@"%d", targetInt];
NSString *resultStr = [strNum substringWithRange:NSMakeRange(strNum.length - 1, 1)];
return [resultStr integerValue];
}
+ (NSInteger)getTens:(NSInteger)targetInt {
if (targetInt < 10 && targetInt > -10) {
return 0;
}
NSString *strNum = [NSString stringWithFormat:@"%d", targetInt];
NSString *resultStr = [strNum substringWithRange:NSMakeRange(strNum.length - 2, 1)];
return [resultStr integerValue];
}
+ (NSInteger)getHundreds:(NSInteger)targetInt {
if (targetInt < 100 && targetInt > -100) {
return 0;
}
NSString *strNum = [NSString stringWithFormat:@"%d", targetInt];
NSString *resultStr = [strNum substringWithRange:NSMakeRange(strNum.length - 3, 1)];
return [resultStr integerValue];
}
IOS 整数取个十百位数
最新推荐文章于 2022-10-27 10:25:12 发布