[Haskell-cafe] Binary constants in Haskell

Ketil Malde ketil+haskell at ii.uib.no
Thu Oct 25 02:42:40 EDT 2007


Don Stewart <dons at galois.com> writes:

>> Are there binary constants in Haskell, as
>> we have, for instance, 0o232 for octal and
>> 0xD29A for hexadecimal?

> No, though it is an interesting idea.

Presumably it is less common since octal and hexadecimal are more
compact and almost as easy to interpret as bit patterns?  Why would
you want them?

    Prelude> let bin = foldl...
    Prelude> 0o232
    154
    Prelude> bin [0,1,0, 0,1,1, 0,1,0]
    154
    Prelude> 0xD29A
    53914
    Prelude> bin [1,1,0,1, 0,0,1,0, 1,0,0,1, 1,0,1,0]
    53914

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants


More information about the Haskell-Cafe mailing list