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 |
Signed integer types
Signed integer types
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 # | Since: base-2.1 |
Enum Int # | Since: base-2.1 |
Eq Int | |
Integral Int # | Since: base-2.0.1 |
Data Int # | Since: base-4.0.0.0 |
Defined in Data.Data 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 t => (forall d. Data d => c (t d)) -> Maybe (c Int) # dataCast2 :: Typeable 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 # | Since: base-2.1 |
Ord Int | |
Read Int # | Since: base-2.1 |
Real Int # | Since: base-2.0.1 |
Defined in GHC.Real toRational :: Int -> Rational # | |
Show Int # | Since: base-2.1 |
Ix Int # | Since: base-2.1 |
FiniteBits Int # | Since: base-4.6.0.0 |
Defined in Data.Bits | |
Bits Int # | Since: base-2.1 |
Defined in Data.Bits | |
Storable Int # | Since: base-2.1 |
Defined in Foreign.Storable | |
PrintfArg Int # | Since: base-2.1 |
Defined in Text.Printf formatArg :: Int -> FieldFormatter # parseFormat :: Int -> ModifierParser # | |
Generic1 (URec Int :: k -> Type) # | |
Functor (URec Int :: Type -> Type) # | Since: base-4.9.0.0 |
Foldable (URec Int :: Type -> Type) # | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => URec Int m -> m # foldMap :: Monoid m => (a -> m) -> URec Int a -> m # foldr :: (a -> b -> b) -> b -> URec Int a -> b # foldr' :: (a -> b -> b) -> b -> URec Int a -> b # foldl :: (b -> a -> b) -> b -> URec Int a -> b # foldl' :: (b -> a -> b) -> b -> URec Int a -> b # foldr1 :: (a -> a -> a) -> URec Int a -> a # foldl1 :: (a -> a -> a) -> URec Int a -> a # elem :: Eq a => a -> URec Int a -> Bool # maximum :: Ord a => URec Int a -> a # minimum :: Ord a => URec Int a -> a # | |
Traversable (URec Int :: Type -> Type) # | Since: base-4.9.0.0 |
Eq (URec Int p) # | Since: base-4.9.0.0 |
Ord (URec Int p) # | Since: base-4.9.0.0 |
Defined in GHC.Generics compare :: URec Int p -> URec Int p -> Ordering Source # (<) :: URec Int p -> URec Int p -> Bool Source # (<=) :: URec Int p -> URec Int p -> Bool Source # (>) :: URec Int p -> URec Int p -> Bool Source # (>=) :: URec Int p -> URec Int p -> Bool Source # | |
Show (URec Int p) # | Since: base-4.9.0.0 |
Generic (URec Int p) # | |
data URec Int (p :: k) # | Used for marking occurrences of Since: base-4.9.0.0 |
type Rep1 (URec Int :: k -> Type) # | Since: base-4.9.0.0 |
Defined in GHC.Generics | |
type Rep (URec Int p) # | Since: base-4.9.0.0 |
Defined in GHC.Generics |
8-bit signed integer type
Instances
Bounded Int8 # | Since: base-2.1 |
Enum Int8 # | Since: base-2.1 |
Eq Int8 # | Since: base-2.1 |
Integral Int8 # | Since: base-2.1 |
Data Int8 # | Since: base-4.0.0.0 |
Defined in Data.Data 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 t => (forall d. Data d => c (t d)) -> Maybe (c Int8) # dataCast2 :: Typeable 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 # | Since: base-2.1 |
Ord Int8 # | Since: base-2.1 |
Read Int8 # | Since: base-2.1 |
Real Int8 # | Since: base-2.1 |
Defined in GHC.Int toRational :: Int8 -> Rational # | |
Show Int8 # | Since: base-2.1 |
Ix Int8 # | Since: base-2.1 |
FiniteBits Int8 # | Since: base-4.6.0.0 |
Defined in GHC.Int | |
Bits Int8 # | Since: base-2.1 |
Defined in GHC.Int (.&.) :: Int8 -> Int8 -> Int8 # (.|.) :: Int8 -> Int8 -> Int8 # complement :: Int8 -> Int8 # shift :: Int8 -> Int -> Int8 # rotate :: Int8 -> Int -> Int8 # setBit :: Int8 -> Int -> Int8 # clearBit :: Int8 -> Int -> Int8 # complementBit :: Int8 -> Int -> Int8 # testBit :: Int8 -> Int -> Bool # bitSizeMaybe :: Int8 -> Maybe Int # shiftL :: Int8 -> Int -> Int8 # unsafeShiftL :: Int8 -> Int -> Int8 # shiftR :: Int8 -> Int -> Int8 # unsafeShiftR :: Int8 -> Int -> Int8 # rotateL :: Int8 -> Int -> Int8 # | |
Storable Int8 # | Since: base-2.1 |
Defined in Foreign.Storable | |
PrintfArg Int8 # | Since: base-2.1 |
Defined in Text.Printf formatArg :: Int8 -> FieldFormatter # parseFormat :: Int8 -> ModifierParser # |
16-bit signed integer type
Instances
Bounded Int16 # | Since: base-2.1 |
Enum Int16 # | Since: base-2.1 |
Eq Int16 # | Since: base-2.1 |
Integral Int16 # | Since: base-2.1 |
Data Int16 # | Since: base-4.0.0.0 |
Defined in Data.Data 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 t => (forall d. Data d => c (t d)) -> Maybe (c Int16) # dataCast2 :: Typeable 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 # | Since: base-2.1 |
Ord Int16 # | Since: base-2.1 |
Read Int16 # | Since: base-2.1 |
Real Int16 # | Since: base-2.1 |
Defined in GHC.Int toRational :: Int16 -> Rational # | |
Show Int16 # | Since: base-2.1 |
Ix Int16 # | Since: base-2.1 |
FiniteBits Int16 # | Since: base-4.6.0.0 |
Defined in GHC.Int finiteBitSize :: Int16 -> Int # countLeadingZeros :: Int16 -> Int # countTrailingZeros :: Int16 -> Int # | |
Bits Int16 # | Since: base-2.1 |
Defined in GHC.Int (.&.) :: 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 # | Since: base-2.1 |
PrintfArg Int16 # | Since: base-2.1 |
Defined in Text.Printf formatArg :: Int16 -> FieldFormatter # parseFormat :: Int16 -> ModifierParser # |
32-bit signed integer type
Instances
Bounded Int32 # | Since: base-2.1 |
Enum Int32 # | Since: base-2.1 |
Eq Int32 # | Since: base-2.1 |
Integral Int32 # | Since: base-2.1 |
Data Int32 # | Since: base-4.0.0.0 |
Defined in Data.Data 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 t => (forall d. Data d => c (t d)) -> Maybe (c Int32) # dataCast2 :: Typeable 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 # | Since: base-2.1 |
Ord Int32 # | Since: base-2.1 |
Read Int32 # | Since: base-2.1 |
Real Int32 # | Since: base-2.1 |
Defined in GHC.Int toRational :: Int32 -> Rational # | |
Show Int32 # | Since: base-2.1 |
Ix Int32 # | Since: base-2.1 |
FiniteBits Int32 # | Since: base-4.6.0.0 |
Defined in GHC.Int finiteBitSize :: Int32 -> Int # countLeadingZeros :: Int32 -> Int # countTrailingZeros :: Int32 -> Int # | |
Bits Int32 # | Since: base-2.1 |
Defined in GHC.Int (.&.) :: 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 # | Since: base-2.1 |
PrintfArg Int32 # | Since: base-2.1 |
Defined in Text.Printf formatArg :: Int32 -> FieldFormatter # parseFormat :: Int32 -> ModifierParser # |
64-bit signed integer type
Instances
Bounded Int64 # | Since: base-2.1 |
Enum Int64 # | Since: base-2.1 |
Eq Int64 # | Since: base-2.1 |
Integral Int64 # | Since: base-2.1 |
Data Int64 # | Since: base-4.0.0.0 |
Defined in Data.Data 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 t => (forall d. Data d => c (t d)) -> Maybe (c Int64) # dataCast2 :: Typeable 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 # | Since: base-2.1 |
Ord Int64 # | Since: base-2.1 |
Read Int64 # | Since: base-2.1 |
Real Int64 # | Since: base-2.1 |
Defined in GHC.Int toRational :: Int64 -> Rational # | |
Show Int64 # | Since: base-2.1 |
Ix Int64 # | Since: base-2.1 |
FiniteBits Int64 # | Since: base-4.6.0.0 |
Defined in GHC.Int finiteBitSize :: Int64 -> Int # countLeadingZeros :: Int64 -> Int # countTrailingZeros :: Int64 -> Int # | |
Bits Int64 # | Since: base-2.1 |
Defined in GHC.Int (.&.) :: 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 # | Since: base-2.1 |
PrintfArg Int64 # | Since: base-2.1 |
Defined in Text.Printf formatArg :: Int64 -> FieldFormatter # parseFormat :: Int64 -> ModifierParser # |
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.