iOS 进制转换(2转10,10转16)

1.     2进制转10进制

NSString * nb = @"110000000000000000000000000000010100000000100000";

long nice = strtol([nb UTF8String], NULL, 2);

NSLog(@"nict==%ld", nice);

 

2.    10进制转16进制

NSString * hexString=[[NSString alloc]initWithFormat:@"%lx”,nice];

NSLog(@“%@”,hexString);

posted @ 2015-06-30 17:22  tongyuling  阅读(423)  评论(0编辑  收藏  举报