看着80%单个文件超过2000行的工程,变量横飞,我低头沉思:尼玛你是怎么运行起来的。。。于是忍着想杀人的冲动,静下心来,看到一堆公式中有这些函数写于此。。不断更新
isnan
如果一个数是一个确定的数,那它就不是nan值
如果一个数是无穷大,无穷小,那它就是nan值
if (isnan(1)) {
DLog(@"1是NAN");
} else {
DLog(@"1不是NAN");
}
abs
int abs(int i); // 处理int类型的取绝对值
fabs
double fabs(double i); //处理double类型的取绝对值
fabsf
float fabsf(float i); /处理float类型的取绝对值
ceilf 进位方法
float numberToRound;
int result;
numberToRound = 5.61;
result = (int)ceilf(numberToRound);
NSLog(@"ceilf(%.2f) = %d", numberToRound, result);
//输出 ceilf(5.61) = 6
numberToRound = 5.41;
result = (int)ceilf(numberToRound);
NSLog(@"ceilf(%.2f) = %d", numberToRound, result);
//输出 ceilf(5.41) = 6
roundf 四舍五入
float numberToRound;
int result;
numberToRound = 5.61;
result = (int)roundf(numberToRound);
NSLog(@"roundf(%.2f) = %d", numberToRound, result);
//输出 roundf(5.61) = 6
numberToRound = 5.41;
result = (int)roundf(numberToRound);
NSLog(@"roundf(%.2f) = %d", numberToRound, result);
//输出 roundf(5.41) = 5
roundf 模位方法
float numberToRound;
int result;
numberToRound = 5.61;
result = (int)floorf(numberToRound);
NSLog(@"floorf(%.2f) = %d", numberToRound, result);
//输出 floorf(5.61) = 5
numberToRound = 5.41;
result = (int)floorf(numberToRound);
NSLog(@"floorf(%.2f) = %d", numberToRound, result);
//输出 floorf(5.41) = 5