1 {-# OPTIONS -fno-implicit-prelude #-}
2 -----------------------------------------------------------------------------
3 -- |
4 -- Module : Data.Int
5 -- Copyright : (c) The University of Glasgow 2001
7 --
9 -- Stability : experimental
10 -- Portability : portable
11 --
12 -- Signed integer types
13 --
14 -----------------------------------------------------------------------------
16 module Data.Int
17 (
18 -- * Signed integer types
19 Int,
20 Int8, Int16, Int32, Int64,
22 -- * Notes
24 -- \$notes
25 ) where
28 import GHC.Base ( Int )
29 import GHC.Int ( Int8, Int16, Int32, Int64 )
30 #endif
32 #ifdef __HUGS__
33 import Hugs.Int ( Int8, Int16, Int32, Int64 )
34 #endif
36 #ifdef __NHC__
37 import Prelude
38 import Prelude (Int)
39 import NHC.FFI (Int8, Int16, Int32, Int64)
40 #endif
42 {- \$notes
44 * All arithmetic is performed modulo 2^n, where @n@ is the number of
45 bits in the type.
47 * For coercing between any two integer types, use 'fromIntegral',
48 which is specialized for all the common cases so should be fast
49 enough. Coercing word types (see "Data.Word") to and from integer
50 types preserves representation, not sign.
52 * The rules that hold for 'Enum' instances over a
53 bounded type such as 'Int' (see the section of the
54 Haskell report dealing with arithmetic sequences) also hold for the
55 'Enum' instances over the various
56 'Int' types defined here.
58 * Right and left shifts by amounts greater than or equal to the width
59 of the type result in either zero or -1, depending on the sign of
60 the value being shifted. This is contrary to the behaviour in C,
61 which is undefined; a common interpretation is to truncate the shift
62 count to the width of the type, for example @1 \<\< 32
63 == 1@ in some C implementations.
64 -}