Non-decimal radices/Convert: Difference between revisions

Line 586:
 
=={{header|Haskell}}==
 
Using built-in functions to convert integer into string, and vice versa, at any base up to 16:
 
<lang haskell>Prelude> Numeric.showIntAtBase 16 Char.intToDigit 42 ""
"2a"
Prelude> fst $ head $ Numeric.readInt 16 Char.isHexDigit Char.digitToInt "2a"
42</lang>
 
It's actually more useful to represent digits internally as numbers instead of characters, because then one can define operations that work directly on this representation.
Anonymous user