#### Binary to Decimal

and 12 more contributors
```def bin_to_decimal(bin_string: str) -> int:
"""
Convert a binary value to its decimal equivalent

>>> bin_to_decimal("101")
5
>>> bin_to_decimal(" 1010   ")
10
>>> bin_to_decimal("-11101")
-29
>>> bin_to_decimal("0")
0
>>> bin_to_decimal("a")
Traceback (most recent call last):
...
ValueError: Non-binary value was passed to the function
>>> bin_to_decimal("")
Traceback (most recent call last):
...
ValueError: Empty string was passed to the function
>>> bin_to_decimal("39")
Traceback (most recent call last):
...
ValueError: Non-binary value was passed to the function
"""
bin_string = str(bin_string).strip()
if not bin_string:
raise ValueError("Empty string was passed to the function")
is_negative = bin_string == "-"
if is_negative:
bin_string = bin_string[1:]
if not all(char in "01" for char in bin_string):
raise ValueError("Non-binary value was passed to the function")
decimal_number = 0
for char in bin_string:
decimal_number = 2 * decimal_number + int(char)
return -decimal_number if is_negative else decimal_number

if __name__ == "__main__":
from doctest import testmod

testmod()
```
{"ft_lang_label":"__label__en","ft_lang_prob":0.5312704,"math_prob":0.9761262,"size":1094,"snap":"2022-27-2022-33","text_gpt3_token_len":270,"char_repetition_ratio":0.19449541,"word_repetition_ratio":0.21678321,"special_character_ratio":0.3190128,"punctuation_ratio":0.14634146,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98424506,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-07-01T23:57:45Z\",\"WARC-Record-ID\":\"<urn:uuid:7a9c0407-94f2-44b8-bc7f-de2ba5cecac9>\",\"Content-Length\":\"114443\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:7652b815-0443-4df3-a4f5-b4083908b227>\",\"WARC-Concurrent-To\":\"<urn:uuid:0ec4c181-23d2-420c-b54c-03ea5014834e>\",\"WARC-IP-Address\":\"76.76.21.21\",\"WARC-Target-URI\":\"https://the-algorithms.com/algorithm/binary-to-decimal\",\"WARC-Payload-Digest\":\"sha1:FVPFOAZB2PA3PWBV7SQVTZPZWE4NTY3L\",\"WARC-Block-Digest\":\"sha1:QJ6NQH6OSFYVMIUD7EDSF3P2ZOXENBK6\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656103947269.55_warc_CC-MAIN-20220701220150-20220702010150-00287.warc.gz\"}"}