Copyright | (c) The University of Glasgow 2001 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | libraries@haskell.org |
Stability | experimental |
Portability | portable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Data.Int
Contents
Description
Signed integer types
Signed integer types
data Int :: TYPE Lifted Source
A fixed-precision integer type with at least the range [-2^29 .. 2^29-1]
.
The exact range for a given implementation can be determined by using
minBound
and maxBound
from the Bounded
class.
Instances
Bounded Int | |
Enum Int | |
Eq Int | |
Integral Int | |
Data Int | |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int -> c Int gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int dataTypeOf :: Int -> DataType dataCast1 :: Typeable (TYPE Lifted -> TYPE Lifted) t => (forall d. Data d => c (t d)) -> Maybe (c Int) dataCast2 :: Typeable (TYPE Lifted -> TYPE Lifted -> TYPE Lifted) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int) gmapT :: (forall b. Data b => b -> b) -> Int -> Int gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int -> r gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int -> r gmapQ :: (forall d. Data d => d -> u) -> Int -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Int -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int -> m Int gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int -> m Int gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int -> m Int | |
Num Int | |
Ord Int | |
Read Int | |
Real Int | |
Methods toRational :: Int -> Rational | |
Show Int | |
Ix Int | |
FiniteBits Int | |
Bits Int | |
Methods complement :: Int -> Int complementBit :: Int -> Int -> Int bitSizeMaybe :: Int -> Maybe Int unsafeShiftL :: Int -> Int -> Int unsafeShiftR :: Int -> Int -> Int | |
Storable Int | |
PrintfArg Int | |
Eq (URec Int p) | |
Ord (URec Int p) | |
Show (URec Int p) | |
Generic (URec Int p) | |
data URec Int = UInt {} | Used for marking occurrences of |
type Rep (URec Int p) = D1 (MetaData "URec" "GHC.Generics" "base" False) (C1 (MetaCons "UInt" PrefixI True) (S1 (MetaSel (Just Symbol "uInt#") NoSourceUnpackedness NoSourceStrictness DecidedLazy) UInt)) |
data Int8
8-bit signed integer type
Instances
Bounded Int8 | |
Enum Int8 | |
Eq Int8 | |
Integral Int8 | |
Data Int8 | |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int8 -> c Int8 gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int8 dataTypeOf :: Int8 -> DataType dataCast1 :: Typeable (TYPE Lifted -> TYPE Lifted) t => (forall d. Data d => c (t d)) -> Maybe (c Int8) dataCast2 :: Typeable (TYPE Lifted -> TYPE Lifted -> TYPE Lifted) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int8) gmapT :: (forall b. Data b => b -> b) -> Int8 -> Int8 gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int8 -> r gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int8 -> r gmapQ :: (forall d. Data d => d -> u) -> Int8 -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Int8 -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int8 -> m Int8 gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int8 -> m Int8 gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int8 -> m Int8 | |
Num Int8 | |
Ord Int8 | |
Read Int8 | |
Real Int8 | |
Methods toRational :: Int8 -> Rational | |
Show Int8 | |
Ix Int8 | |
FiniteBits Int8 | |
Methods finiteBitSize :: Int8 -> Int countLeadingZeros :: Int8 -> Int countTrailingZeros :: Int8 -> Int | |
Bits Int8 | |
Storable Int8 | |
PrintfArg Int8 | |
data Int16
16-bit signed integer type
Instances
Bounded Int16 | |
Enum Int16 | |
Eq Int16 | |
Integral Int16 | |
Data Int16 | |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int16 -> c Int16 gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int16 dataTypeOf :: Int16 -> DataType dataCast1 :: Typeable (TYPE Lifted -> TYPE Lifted) t => (forall d. Data d => c (t d)) -> Maybe (c Int16) dataCast2 :: Typeable (TYPE Lifted -> TYPE Lifted -> TYPE Lifted) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int16) gmapT :: (forall b. Data b => b -> b) -> Int16 -> Int16 gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int16 -> r gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int16 -> r gmapQ :: (forall d. Data d => d -> u) -> Int16 -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Int16 -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int16 -> m Int16 gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int16 -> m Int16 gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int16 -> m Int16 | |
Num Int16 | |
Ord Int16 | |
Read Int16 | |
Real Int16 | |
Methods toRational :: Int16 -> Rational | |
Show Int16 | |
Ix Int16 | |
FiniteBits Int16 | |
Methods finiteBitSize :: Int16 -> Int countLeadingZeros :: Int16 -> Int countTrailingZeros :: Int16 -> Int | |
Bits Int16 | |
Methods (.&.) :: Int16 -> Int16 -> Int16 (.|.) :: Int16 -> Int16 -> Int16 xor :: Int16 -> Int16 -> Int16 complement :: Int16 -> Int16 shift :: Int16 -> Int -> Int16 rotate :: Int16 -> Int -> Int16 setBit :: Int16 -> Int -> Int16 clearBit :: Int16 -> Int -> Int16 complementBit :: Int16 -> Int -> Int16 testBit :: Int16 -> Int -> Bool bitSizeMaybe :: Int16 -> Maybe Int shiftL :: Int16 -> Int -> Int16 unsafeShiftL :: Int16 -> Int -> Int16 shiftR :: Int16 -> Int -> Int16 unsafeShiftR :: Int16 -> Int -> Int16 rotateL :: Int16 -> Int -> Int16 | |
Storable Int16 | |
PrintfArg Int16 | |
data Int32
32-bit signed integer type
Instances
Bounded Int32 | |
Enum Int32 | |
Eq Int32 | |
Integral Int32 | |
Data Int32 | |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int32 -> c Int32 gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int32 dataTypeOf :: Int32 -> DataType dataCast1 :: Typeable (TYPE Lifted -> TYPE Lifted) t => (forall d. Data d => c (t d)) -> Maybe (c Int32) dataCast2 :: Typeable (TYPE Lifted -> TYPE Lifted -> TYPE Lifted) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int32) gmapT :: (forall b. Data b => b -> b) -> Int32 -> Int32 gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int32 -> r gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int32 -> r gmapQ :: (forall d. Data d => d -> u) -> Int32 -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Int32 -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int32 -> m Int32 gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int32 -> m Int32 gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int32 -> m Int32 | |
Num Int32 | |
Ord Int32 | |
Read Int32 | |
Real Int32 | |
Methods toRational :: Int32 -> Rational | |
Show Int32 | |
Ix Int32 | |
FiniteBits Int32 | |
Methods finiteBitSize :: Int32 -> Int countLeadingZeros :: Int32 -> Int countTrailingZeros :: Int32 -> Int | |
Bits Int32 | |
Methods (.&.) :: Int32 -> Int32 -> Int32 (.|.) :: Int32 -> Int32 -> Int32 xor :: Int32 -> Int32 -> Int32 complement :: Int32 -> Int32 shift :: Int32 -> Int -> Int32 rotate :: Int32 -> Int -> Int32 setBit :: Int32 -> Int -> Int32 clearBit :: Int32 -> Int -> Int32 complementBit :: Int32 -> Int -> Int32 testBit :: Int32 -> Int -> Bool bitSizeMaybe :: Int32 -> Maybe Int shiftL :: Int32 -> Int -> Int32 unsafeShiftL :: Int32 -> Int -> Int32 shiftR :: Int32 -> Int -> Int32 unsafeShiftR :: Int32 -> Int -> Int32 rotateL :: Int32 -> Int -> Int32 | |
Storable Int32 | |
PrintfArg Int32 | |
data Int64
64-bit signed integer type
Instances
Bounded Int64 | |
Enum Int64 | |
Eq Int64 | |
Integral Int64 | |
Data Int64 | |
Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int64 -> c Int64 gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int64 dataTypeOf :: Int64 -> DataType dataCast1 :: Typeable (TYPE Lifted -> TYPE Lifted) t => (forall d. Data d => c (t d)) -> Maybe (c Int64) dataCast2 :: Typeable (TYPE Lifted -> TYPE Lifted -> TYPE Lifted) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int64) gmapT :: (forall b. Data b => b -> b) -> Int64 -> Int64 gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int64 -> r gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int64 -> r gmapQ :: (forall d. Data d => d -> u) -> Int64 -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> Int64 -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int64 -> m Int64 | |
Num Int64 | |
Ord Int64 | |
Read Int64 | |
Real Int64 | |
Methods toRational :: Int64 -> Rational | |
Show Int64 | |
Ix Int64 | |
FiniteBits Int64 | |
Methods finiteBitSize :: Int64 -> Int countLeadingZeros :: Int64 -> Int countTrailingZeros :: Int64 -> Int | |
Bits Int64 | |
Methods (.&.) :: Int64 -> Int64 -> Int64 (.|.) :: Int64 -> Int64 -> Int64 xor :: Int64 -> Int64 -> Int64 complement :: Int64 -> Int64 shift :: Int64 -> Int -> Int64 rotate :: Int64 -> Int -> Int64 setBit :: Int64 -> Int -> Int64 clearBit :: Int64 -> Int -> Int64 complementBit :: Int64 -> Int -> Int64 testBit :: Int64 -> Int -> Bool bitSizeMaybe :: Int64 -> Maybe Int shiftL :: Int64 -> Int -> Int64 unsafeShiftL :: Int64 -> Int -> Int64 shiftR :: Int64 -> Int -> Int64 unsafeShiftR :: Int64 -> Int -> Int64 rotateL :: Int64 -> Int -> Int64 | |
Storable Int64 | |
PrintfArg Int64 | |
Notes
- All arithmetic is performed modulo 2^n, where
n
is the number of bits in the type. - For coercing between any two integer types, use
fromIntegral
, which is specialized for all the common cases so should be fast enough. Coercing word types (see Data.Word) to and from integer types preserves representation, not sign. - The rules that hold for
Enum
instances over a bounded type such asInt
(see the section of the Haskell report dealing with arithmetic sequences) also hold for theEnum
instances over the variousInt
types defined here. - Right and left shifts by amounts greater than or equal to the width
of the type result in either zero or -1, depending on the sign of
the value being shifted. This is contrary to the behaviour in C,
which is undefined; a common interpretation is to truncate the shift
count to the width of the type, for example
1 << 32 == 1
in some C implementations.