[project @ 2002-05-11 08:59:08 by panne]
[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.Base ( Int )
29 import GHC.Int  ( Int8, Int16, Int32, Int64 )
30 #endif
31
32 {- $notes
33
34 * All arithmetic is performed modulo 2^n, where @n@ is the number of
35   bits in the type.
36
37 * For coercing between any two integer types, use 'fromIntegral',
38   which is specialized for all the common cases so should be fast
39   enough.  Coercing word types (see "Data.Word") to and from integer
40   types preserves representation, not sign.
41
42 * The rules that hold for 'Enum' instances over a
43   bounded type such as 'Int' (see the section of the
44   Haskell report dealing with arithmetic sequences) also hold for the
45   'Enum' instances over the various
46   'Int' types defined here.
47
48 * Right and left shifts by amounts greater than or equal to the width
49   of the type result in either zero or -1, depending on the sign of
50   the value being shifted.  This is contrary to the behaviour in C,
51   which is undefined; a common interpretation is to truncate the shift
52   count to the width of the type, for example @1 \<\< 32
53   == 1@ in some C implementations.
54 -}