def bin2dec(x):
    """Convert ``x``, an array of "bits" (MSB first), to it's decimal value."""
    bits = []
    bits.extend(x)
    bits.reverse()  # MSB

    multi = 1
    value = 0
    for b in bits:
        value += b * multi
        multi *= 2
    return value