iphone-common-codes-ccteam源代码 CCNSNumber.m
2012-01-01 12:02
417 查看
// // CCNSNumber.m // CCFC // // Created by xichen on 11-12-17. // Copyright 2011年 ccteam. All rights reserved. // #import "CCNSNumber.h" #import <math.h> @implementation NSNumber(cc) - (BOOL)floatEqualToZero { return FLOAT_EQUAL_TO_ZERO([self floatValue]); } - (BOOL)floatEqualToFloat:(NSNumber *)another { return FLOAT_EQUAL_TO_FLOAT([self floatValue], [another floatValue]); } // 判断两个整形加法是否溢出 + (int)addCheckOverflow:(int)a withB:(int)b overFlow:(int *)overFlowFlag { int sum = a + b; *overFlowFlag = 0; if(a > 0 && b > 0 && sum < 0 || a < 0 && b < 0 && sum > 0) { *overFlowFlag = 1; } return sum; } // 整型转换成字符串,返回转换后的字符串的实际长度 + (int)itoa:(char *)str maxLen:(const int)maxLen num:(int)n { char temp[32] = {0}; int i = 0; while(n) { if(i >= 32) { return -1; } temp[i++] = (n % 10) + '0'; // 将整型数的各位对应的字符值保存在数组中 n /= 10; } if(i > maxLen) // 长度过长,返回0 { return -1; } int len = i; int j = 0; while (i >= 0) { str[j++] = temp[--i]; // 拷贝到外部字符串中 } str[i] = '\0'; return len; } // 根据角度获取弧度值 + (double)getRadiusByDegrees:(double)degrees { return degrees * M_PI / 180; } @end
可能有更新:
googlecode链接地址:http://code.google.com/p/iphone-common-codes-ccteam/source/browse/trunk/CCFC/files/CCNSNumber.m
github地址: https://github.com/cxsjabc/iphone-common-codes-ccteam/tree/master/CCFC/files/CCNSNumber.m
相关文章推荐
- iphone-common-codes-ccteam源代码 CCNSNumber.h
- iphone-common-codes-ccteam源代码 CCCompile.m
- iphone-common-codes-ccteam源代码 CCFoundation.m
- iphone-common-codes-ccteam源代码 CCLanguage.h
- iphone-common-codes-ccteam源代码 CCNSLocale.m
- iphone-common-codes-ccteam源代码 CCSize.h
- iphone-common-codes-ccteam源代码 CCConfig.h
- iphone-common-codes-ccteam源代码 CCLanguage.m
- iphone-common-codes-ccteam源代码 CCSize.m
- iphone-common-codes-ccteam源代码 CCAddressBook.m
- iphone-common-codes-ccteam源代码 CCConfig.m
- iphone-common-codes-ccteam源代码 CCPhoto.h
- iphone-common-codes-ccteam源代码 CCSound.m
- iphone-common-codes-ccteam源代码 CCAudio.h
- iphone-common-codes-ccteam源代码 CCContact.h
- iphone-common-codes-ccteam源代码 CCMemory.h
- iphone-common-codes-ccteam源代码 CCPhoto.m
- iphone-common-codes-ccteam源代码 CCRadix.h
- iphone-common-codes-ccteam源代码 CCSound.h
- iphone-common-codes-ccteam源代码 CCUIBarButtonItem.h