How to print integer literals in binary or hex in haskell?

前端 未结 8 1199
说谎
说谎 2021-01-30 02:13

How to print integer literals in binary or hex in haskell?

printBinary 5 => \"0101\"

printHex 5 => \"05\"

Which libraries/functions allo

8条回答
  •  死守一世寂寞
    2021-01-30 03:01

    Hex can be written with 0x and binary with 0b prefix e.g.:

    > 0xff
    255
    >:set -XBinaryLiterals
    > 0b11
    3
    

    Note that binary requires the BinaryLiterals extension.

提交回复
热议问题