[project @ 2002-05-10 16:18:28 by simonmar]
[ghc-base.git] / Data / Int.hs
1 {-# OPTIONS -fno-implicit-prelude #-}
2 -----------------------------------------------------------------------------
3 -- |
4 -- Module      :  Data.Int
5 -- Copyright   :  (c) The University of Glasgow 2001
6 -- License     :  BSD-style (see the file libraries/base/LICENSE)
7 -- 
8 -- Maintainer  :  libraries@haskell.org
9 -- Stability   :  experimental
10 -- Portability :  portable
11 --
12 -- Signed integer types
13 --
14 -----------------------------------------------------------------------------
15
16 module Data.Int
17   ( 
18         -- * Signed integer types
19         Int,
20         Int8, Int16, Int32, Int64,
21
22         -- * Notes
23
24         -- $notes
25         ) where
26
27 #ifdef __GLASGOW_HASKELL__
28 import GHC.Int
29 #endif
30
31 {- $notes
32
33 * All arithmetic is performed modulo 2^n, where @n@ is the number of
34   bits in the type.
35
36 * For coercing between any two integer types, use 'fromIntegral',
37   which is specialized for all the common cases so should be fast
38   enough.  Coercing word types (see "Data.Word") to and from integer
39   types preserves representation, not sign.
40
41 * The rules that hold for 'Enum' instances over a
42   bounded type such as 'Int' (see the section of the
43   Haskell report dealing with arithmetic sequences) also hold for the
44   'Enum' instances over the various
45   'Int' types defined here.
46
47 * Right and left shifts by amounts greater than or equal to the width
48   of the type result in either zero or -1, depending on the sign of
49   the value being shifted.  This is contrary to the behaviour in C,
50   which is undefined; a common interpretation is to truncate the shift
51   count to the width of the type, for example @1 \<\< 32
52   == 1@ in some C implementations.
53 -}