I have written a code to convert hexadecimal numbers into base 10 number
but its working only for 32 bits and I  need it to work upto 160 bits , code
is given below. please help.

--its a program to convert hexadecimal numbers into base 10 numbers

import Char

-- the function "func" takes a list of strings in hexadecimal and convert
-- it to a list of corresponding numbers in decimal format
-- func "eefba12" = [14,14,15,11,10,1,2]

func [] = []
func (x:xs)
   |(ord x > 57) = ((ord x)-87):func xs
   |otherwise  =  ((ord x)-48):func xs

-- (mul.func) function takes a hexadecimal number and convert it to base 10
but its working only for 32 bits
-- whereas haskell supports calculations much higher than 32 bits.....
-- mul.func $ "ee" = 238
-- mul.func $ "e23e" = 57918

mul xs = mul1 xs ((length xs)-1)
mul1 (x:xs) 0 = x
mul1 (x:xs) n = (x*16^n)+ mul1 xs (n-1)
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to