thoga31

Binary converter (Haskell)

Aug 5th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. binario :: Int -> String
  2. binario n = f n (b n)
  3.   where
  4.     b a = reverse . map (2^) $ [0 .. truncate $ log (read $ show a :: Float) / log 2.0]
  5.     f a (x:xs) = (if a >= x then '1' else '0') : (if xs == [] then [] else f (if a >= x then a-x else a) xs)
Advertisement
Add Comment
Please, Sign In to add comment