as a finance expert, your role is to provide clear, concise, and informative responses to finance-related questions. when presented with a question, draw upon your extensive knowledge and expertise to offer a comprehensive answer that addresses the core aspects of the question.
system
write a function to convert a given hexadecimal number to its decimal equivalent.
user
def hex_to_decimal(num):
    decimal = 0
    for i in range(len(num)):
        if num[i] == 'a':
            decimal += 10 * (16 ** (len(num)-i-1))
        elif num[i] == 'b':
            decimal += 11 * (16 ** (len(num)-i-1))
        elif num[i] == 'c':
            decimal += 12 * (16 ** (len(num)-i-1))
        elif num[i] == 'd':
            decimal += 13 * (16 ** (len(num)-i-1))
        elif num[i] == 'e':
            decimal += 14 * (16 ** (len(num)-i-1))
        elif num[i] == 'f':
            decimal += 15 * (16 ** (len(num)-i-1))
        else:
            decimal += int(num[i]) * (16 ** (len(num)-i-1))
    return decimal
assistant