Skip to content

Instantly share code, notes, and snippets.

@Xophmeister
Created October 14, 2015 13:57
Show Gist options
  • Select an option

  • Save Xophmeister/446a57eb72933ed2edbb to your computer and use it in GitHub Desktop.

Select an option

Save Xophmeister/446a57eb72933ed2edbb to your computer and use it in GitHub Desktop.
Binary string to integer
int bin2int(const char* s) {
int out = 0;
while (*s) {
out <<= 1;
if (*s == '1') ++out;
++s;
}
return out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment