iOS 超简单的进制转换
1. 十六进制转十进制
NSString*hex2 =@"A3";
QLog(@"%lu",strtoul(hex2.UTF8String,0,16));
2. 十进制转十六进制
NSString*hex = [NSStringstringWithFormat:@"%x",tmpid];
while(hex.length%2!=0){
hex = [NSStringstringWithFormat:@"0%@",hex];
}
NSLog(@"%@",hex);
网友评论