1 {-# LANGUAGE CPP, NoImplicitPrelude #-}
3 -----------------------------------------------------------------------------
6 -- Copyright : (c) The University of Glasgow 2001
7 -- License : BSD-style (see the file libraries/base/LICENSE)
9 -- Maintainer : libraries@haskell.org
10 -- Stability : experimental
11 -- Portability : portable
13 -- Signed integer types
15 -----------------------------------------------------------------------------
19 -- * Signed integer types
21 Int8, Int16, Int32, Int64,
28 #ifdef __GLASGOW_HASKELL__
29 import GHC.Base ( Int )
30 import GHC.Int ( Int8, Int16, Int32, Int64 )
34 import Hugs.Int ( Int8, Int16, Int32, Int64 )
40 import NHC.FFI (Int8, Int16, Int32, Int64)
41 import NHC.SizedTypes (Int8, Int16, Int32, Int64) -- instances of Bits
46 * All arithmetic is performed modulo 2^n, where @n@ is the number of
49 * For coercing between any two integer types, use 'Prelude.fromIntegral',
50 which is specialized for all the common cases so should be fast
51 enough. Coercing word types (see "Data.Word") to and from integer
52 types preserves representation, not sign.
54 * The rules that hold for 'Prelude.Enum' instances over a
55 bounded type such as 'Int' (see the section of the
56 Haskell report dealing with arithmetic sequences) also hold for the
57 'Prelude.Enum' instances over the various
58 'Int' types defined here.
60 * Right and left shifts by amounts greater than or equal to the width
61 of the type result in either zero or -1, depending on the sign of
62 the value being shifted. This is contrary to the behaviour in C,
63 which is undefined; a common interpretation is to truncate the shift
64 count to the width of the type, for example @1 \<\< 32
65 == 1@ in some C implementations.