ios判断数(int float double bool)
2013-02-20 13:53
351 查看
+(NSString*)fromTypeToString:(id)data{
NSNumber *myNumber = (NSNumber *)data;
int minThreshold = [myNumber
intValue];
if ((int)minThreshold <
1 )
{
NSLog(@"Not a number");
}
else{
if (strcmp([myNumber
objCType], @encode(BOOL)) ==
0) {
returnString = @"BOOL";
NSLog(@"this is a bool");
} else if (strcmp([myNumber
objCType], @encode(int)) ==
0) {
returnString = @"int";
NSLog(@"this is an int");
}
else if (strcmp([myNumber
objCType], @encode(float)) ==
0) {
returnString = @"float";
NSLog(@"this is an float");
}
else if (strcmp([myNumber
objCType], @encode(double)) ==
0) {
returnString = @"double";
NSLog(@"this is an double");
}
NSNumber *myNumber = (NSNumber *)data;
int minThreshold = [myNumber
intValue];
if ((int)minThreshold <
1 )
{
NSLog(@"Not a number");
}
else{
if (strcmp([myNumber
objCType], @encode(BOOL)) ==
0) {
returnString = @"BOOL";
NSLog(@"this is a bool");
} else if (strcmp([myNumber
objCType], @encode(int)) ==
0) {
returnString = @"int";
NSLog(@"this is an int");
}
else if (strcmp([myNumber
objCType], @encode(float)) ==
0) {
returnString = @"float";
NSLog(@"this is an float");
}
else if (strcmp([myNumber
objCType], @encode(double)) ==
0) {
returnString = @"double";
NSLog(@"this is an double");
}
相关文章推荐
- 【Mac/iOS】Swift-String转Int/Float/Double/Bool
- 有int d; int *d; bool d; double d;判断这个四个变量是否等于0?
- C# 判断字符串为数字 int float double
- 如何判断int、double、float类型数据为0或判断一个未知数据类型的为0或相等
- 如何判断int、double、float类型数据为0或判断一个未知数据类型的为0或相等
- int bool double float各类型数值相同数值是否存在差异
- C++ bool,char,short,int,long,float,double数据类型大小以及数据溢出值求解
- ios开发求数值的double、float、int类型值的绝对值的函数
- bool、int、float、double变量与0值的比较
- iOS 基本数据类型~int、float、double、char格式化字符串
- IOS将Int64转换为Int,Double,Float等类型
- BOOL,int,float,指针变量 与“零值”比较的if语句
- IOS Number 处理(int-->NSNumber,NSNumber-->nsinteger,string -->double,CGFloat --> dobule)
- java里short,int,long,float,double范围及可写位数
- c语言基本数据类型short、int、long、char、float、double
- C# double float int string 与 byte数组 相互转化
- Android中 int,float,Double,String 互相转换
- 一个函数将int,float,double等类型转string
- float数据 与 double数据相乘时,结果转成int时会出现错误
- MFC----Cstring 与 int、float、double 数据类型的相互转换