Sha256: 65cf8b7de4adaf2f05d6fb5b43fd35713f76ce8b44250c9885363650df1d43d2
Contents?: true
Size: 334 Bytes
Versions: 311
Compression:
Stored size: 334 Bytes
Contents
#include "binary.h" #include <string.h> int convert(const char *input) { size_t input_len = strlen(input); int result = 0; for (size_t i = 0; i < input_len; i++) { result <<= 1; if (input[i] == '1') { result |= 1; } else if (input[i] != '0') { return -1; } } return result; }
Version data entries
311 entries across 311 versions & 1 rubygems