Advertisements
Binary to Hexadecimal Converter
Example Code
NSString *binaryString = @"1111"; /* Binary to Dec*/ NSLog(@"Decimal Value for binary String is %ld", strtol([binaryString UTF8String], NULL, 2)); /* Binary to Hex*/ NSLog(@"Hexadecimal Value for Binary String is %2lX", (unsigned long)strtol([binaryString UTF8String], NULL, 2)); /* Binary to Octal*/ NSLog(@"Octal Value for Binary String is %2lO", (unsigned long)strtol([binaryString UTF8String], NULL, 2));
Result
Decimal Value for Octal String is 15 Hexadecimal Value for Octal String is F Binary Value for Octal String is 1111
Advertisements