[Haskell-beginners] is there a better way to ask for a hex formatted number?

Daniel Fischer daniel.is.fischer at googlemail.com
Fri Apr 29 23:23:30 CEST 2011


On Friday 29 April 2011 23:11:01, Sean Perry wrote:
> I am using this currently:
> 
> makeHex n = "0x" ++ map toUpper (showHex n "") -- gives me 0xFF for
> example
> 
> I know i can use printf but I am not sending this to output when I am
> doing the formatting.
> 

printf can also produce Strings:

Prelude Text.Printf> printf "0x%x" 239 :: String
"0xef"
Prelude Text.Printf> printf "0x%X" 239 :: String
"0xEF"



More information about the Beginners mailing list