看著80%單個文件超過2000行的工程,變量橫飛惧磺,我低頭沉思:尼瑪你是怎么運行起來的颖对。。磨隘。于是忍著想殺人的沖動缤底,靜下心來,看到一堆公式中有這些函數(shù)寫于此番捂。个唧。不斷更新
isnan
如果一個數(shù)是一個確定的數(shù),那它就不是nan值
如果一個數(shù)是無窮大设预,無窮小徙歼,那它就是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