I have binary sequence in a string. How to convert it in decimal. Is there any built in function in Objective C ?
NSString * b = @"1101";
long v = strtol([b UTF8String], NULL, 2);
NSLog(@"%ld", v); //logs 13
The downside of this is that it only appears to produce positive numbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With