Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

binary list to decimal

def binarylist_to_decimal(lst):
    power=0
    nb=0
    for i in range(len(lst)-1,0-1,-1):
        nb+=lst[i]*(2**power)
        power+=1
    return nb

bin_lst=[1,1,1,1,1,1,1,1]
power=0
nb=0
print(binarylist_to_decimal(bin_lst))

# 255
 
PREVIOUS NEXT
Tagged: #binary #list #decimal
ADD COMMENT
Topic
Name
8+6 =