File: BinaryLiteralsGood.hs

package info (click to toggle)
haskell-src-exts 1.23.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 25,852 kB
  • sloc: haskell: 13,707; makefile: 12
file content (23 lines) | stat: -rw-r--r-- 1,106 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MagicHash #-}

import GHC.Types

main = do
    print [ I# 0b0#, I# -0b0#, I# 0b1#, I# -0b1#
          , I# 0b00000000000000000000000000000000000000000000000000000000000000000000000000001#
          , I# -0b00000000000000000000000000000000000000000000000000000000000000000000000000001#
          , I# -0b11001001#, I# -0b11001001#
          , I# -0b11111111#, I# -0b11111111#
          ]
    print [ W# 0b0##, W# 0b1##, W# 0b11001001##, W# 0b11##, W# 0b11111111##
          , W# 0b00000000000000000000000000000000000000000000000000000000000000000000000000001##
          ]

    print [ 0b0, 0b1, 0b10, 0b11, 0b100, 0b101, 0b110, 0b111 :: Integer
          , -0b0, -0b1, -0b10, -0b11, -0b100, -0b101, -0b110, -0b111
          , 0b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
          , -0b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
          ]

    print [ I8# -0B10000000#, I8# 0B1111111# ]