conversions.binary_to_decimalยถ
Functionsยถ
|
Convert a binary value to its decimal equivalent |
Module Contentsยถ
- conversions.binary_to_decimal.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