Converting number base

后端 未结 3 912
日久生厌
日久生厌 2021-02-08 14:29

Is there a platform function that will do the following?

convertBase :: (Num a, Num b) => Int -> Int -> [a] -> [b]

Convert a number

3条回答
  •  借酒劲吻你
    2021-02-08 15:06

    Couple of ideas:

    • use showIntAtBase or Text.printf to convert to a string, and convert back to a different base
    • write it yourself -- easier when one base is always a multiple of the other

    Here is a link that might help you: http://rosettacode.org/wiki/Non-decimal_radices/Convert#Haskell -- Non-decimal radices/Convert

提交回复
热议问题