haskell2010-base
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Int

Description

This module provides signed integer types of unspecified width (Int) and fixed widths (Int8, Int16, Int32 and Int64). 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. Coercing word types (see Word) to and from integer types preserves representation, not sign.

The rules that hold for Enum instances over a bounded type such as Int (see the section of the Haskell language report dealing with arithmetic sequences) also hold for the Enum instances over the various Int 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.

Synopsis

Documentation

data Int #

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

Instances details
Bits Int # 
Instance details

Defined in Data.Bits

Methods

(.&.) :: Int -> Int -> Int #

(.|.) :: Int -> Int -> Int #

xor :: Int -> Int -> Int #

complement :: Int -> Int #

shift :: Int -> Int -> Int #

rotate :: Int -> Int -> Int #

bit :: Int -> Int #

setBit :: Int -> Int -> Int #

clearBit :: Int -> Int -> Int #

complementBit :: Int -> Int -> Int #

testBit :: Int -> Int -> Bool #

bitSize :: Int -> Int #

isSigned :: Int -> Bool #

shiftL :: Int -> Int -> Int #

shiftR :: Int -> Int -> Int #

rotateL :: Int -> Int -> Int #

rotateR :: Int -> Int -> Int #

Bounded Int # 
Instance details

Defined in Data.Enum

Methods

minBound :: Int #

maxBound :: Int #

Enum Int # 
Instance details

Defined in Data.Enum

Methods

succ :: Int -> Int #

pred :: Int -> Int #

toEnum :: Int -> Int #

fromEnum :: Int -> Int #

enumFrom :: Int -> [Int] #

enumFromThen :: Int -> Int -> [Int] #

enumFromTo :: Int -> Int -> [Int] #

enumFromThenTo :: Int -> Int -> Int -> [Int] #

Eq Int # 
Instance details

Defined in Data.Eq

Methods

(==) :: Int -> Int -> Bool #

(/=) :: Int -> Int -> Bool #

Ix Int # 
Instance details

Defined in Data.Ix

Methods

range :: (Int, Int) -> [Int] #

index :: (Int, Int) -> Int -> Int #

inRange :: (Int, Int) -> Int -> Bool #

rangeSize :: (Int, Int) -> Int #

Ord Int # 
Instance details

Defined in Data.Ord

Methods

compare :: Int -> Int -> Ordering #

(<) :: Int -> Int -> Bool #

(<=) :: Int -> Int -> Bool #

(>=) :: Int -> Int -> Bool #

(>) :: Int -> Int -> Bool #

max :: Int -> Int -> Int #

min :: Int -> Int -> Int #

Storable Int # 
Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Int -> Int #

alignment :: Int -> Int #

peekElemOff :: Ptr Int -> Int -> IO Int #

pokeElemOff :: Ptr Int -> Int -> Int -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int #

pokeByteOff :: Ptr b -> Int -> Int -> IO () #

peek :: Ptr Int -> IO Int #

poke :: Ptr Int -> Int -> IO () #

Integral Int # 
Instance details

Defined in NumHierarchy

Methods

quot :: Int -> Int -> Int #

rem :: Int -> Int -> Int #

div :: Int -> Int -> Int #

mod :: Int -> Int -> Int #

quotRem :: Int -> Int -> (Int, Int) #

divMod :: Int -> Int -> (Int, Int) #

toInteger :: Int -> Integer #

Num Int # 
Instance details

Defined in NumHierarchy

Methods

(+) :: Int -> Int -> Int #

(-) :: Int -> Int -> Int #

(*) :: Int -> Int -> Int #

negate :: Int -> Int #

abs :: Int -> Int #

signum :: Int -> Int #

fromInteger :: Integer -> Int #

Real Int # 
Instance details

Defined in NumHierarchy

Methods

toRational :: Int -> Rational #

Read Int # 
Instance details

Defined in Text.Read

Show Int # 
Instance details

Defined in Text.Show

Methods

showsPrec :: Int -> Int -> ShowS #

show :: Int -> String #

showList :: [Int] -> ShowS #

data Int8 #

8-bit signed integer type

Instances

Instances details
Bits Int8 # 
Instance details

Defined in Data.Bits

Methods

(.&.) :: Int8 -> Int8 -> Int8 #

(.|.) :: Int8 -> Int8 -> Int8 #

xor :: Int8 -> Int8 -> Int8 #

complement :: Int8 -> Int8 #

shift :: Int8 -> Int -> Int8 #

rotate :: Int8 -> Int -> Int8 #

bit :: Int -> Int8 #

setBit :: Int8 -> Int -> Int8 #

clearBit :: Int8 -> Int -> Int8 #

complementBit :: Int8 -> Int -> Int8 #

testBit :: Int8 -> Int -> Bool #

bitSize :: Int8 -> Int #

isSigned :: Int8 -> Bool #

shiftL :: Int8 -> Int -> Int8 #

shiftR :: Int8 -> Int -> Int8 #

rotateL :: Int8 -> Int -> Int8 #

rotateR :: Int8 -> Int -> Int8 #

Bounded Int8 # 
Instance details

Defined in Data.Enum

Enum Int8 # 
Instance details

Defined in Data.Enum

Methods

succ :: Int8 -> Int8 #

pred :: Int8 -> Int8 #

toEnum :: Int -> Int8 #

fromEnum :: Int8 -> Int #

enumFrom :: Int8 -> [Int8] #

enumFromThen :: Int8 -> Int8 -> [Int8] #

enumFromTo :: Int8 -> Int8 -> [Int8] #

enumFromThenTo :: Int8 -> Int8 -> Int8 -> [Int8] #

Eq Int8 # 
Instance details

Defined in Data.Eq

Methods

(==) :: Int8 -> Int8 -> Bool #

(/=) :: Int8 -> Int8 -> Bool #

Ix Int8 # 
Instance details

Defined in Data.Ix

Methods

range :: (Int8, Int8) -> [Int8] #

index :: (Int8, Int8) -> Int8 -> Int #

inRange :: (Int8, Int8) -> Int8 -> Bool #

rangeSize :: (Int8, Int8) -> Int #

Ord Int8 # 
Instance details

Defined in Data.Ord

Methods

compare :: Int8 -> Int8 -> Ordering #

(<) :: Int8 -> Int8 -> Bool #

(<=) :: Int8 -> Int8 -> Bool #

(>=) :: Int8 -> Int8 -> Bool #

(>) :: Int8 -> Int8 -> Bool #

max :: Int8 -> Int8 -> Int8 #

min :: Int8 -> Int8 -> Int8 #

Storable Int8 # 
Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Int8 -> Int #

alignment :: Int8 -> Int #

peekElemOff :: Ptr Int8 -> Int -> IO Int8 #

pokeElemOff :: Ptr Int8 -> Int -> Int8 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int8 #

pokeByteOff :: Ptr b -> Int -> Int8 -> IO () #

peek :: Ptr Int8 -> IO Int8 #

poke :: Ptr Int8 -> Int8 -> IO () #

Integral Int8 # 
Instance details

Defined in NumHierarchy

Methods

quot :: Int8 -> Int8 -> Int8 #

rem :: Int8 -> Int8 -> Int8 #

div :: Int8 -> Int8 -> Int8 #

mod :: Int8 -> Int8 -> Int8 #

quotRem :: Int8 -> Int8 -> (Int8, Int8) #

divMod :: Int8 -> Int8 -> (Int8, Int8) #

toInteger :: Int8 -> Integer #

Num Int8 # 
Instance details

Defined in NumHierarchy

Methods

(+) :: Int8 -> Int8 -> Int8 #

(-) :: Int8 -> Int8 -> Int8 #

(*) :: Int8 -> Int8 -> Int8 #

negate :: Int8 -> Int8 #

abs :: Int8 -> Int8 #

signum :: Int8 -> Int8 #

fromInteger :: Integer -> Int8 #

Real Int8 # 
Instance details

Defined in NumHierarchy

Methods

toRational :: Int8 -> Rational #

Read Int8 # 
Instance details

Defined in Text.Read

Show Int8 # 
Instance details

Defined in Text.Show

Methods

showsPrec :: Int -> Int8 -> ShowS #

show :: Int8 -> String #

showList :: [Int8] -> ShowS #

data Int16 #

16-bit signed integer type

Instances

Instances details
Bits Int16 # 
Instance details

Defined in Data.Bits

Bounded Int16 # 
Instance details

Defined in Data.Enum

Enum Int16 # 
Instance details

Defined in Data.Enum

Eq Int16 # 
Instance details

Defined in Data.Eq

Methods

(==) :: Int16 -> Int16 -> Bool #

(/=) :: Int16 -> Int16 -> Bool #

Ix Int16 # 
Instance details

Defined in Data.Ix

Methods

range :: (Int16, Int16) -> [Int16] #

index :: (Int16, Int16) -> Int16 -> Int #

inRange :: (Int16, Int16) -> Int16 -> Bool #

rangeSize :: (Int16, Int16) -> Int #

Ord Int16 # 
Instance details

Defined in Data.Ord

Methods

compare :: Int16 -> Int16 -> Ordering #

(<) :: Int16 -> Int16 -> Bool #

(<=) :: Int16 -> Int16 -> Bool #

(>=) :: Int16 -> Int16 -> Bool #

(>) :: Int16 -> Int16 -> Bool #

max :: Int16 -> Int16 -> Int16 #

min :: Int16 -> Int16 -> Int16 #

Storable Int16 # 
Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Int16 -> Int #

alignment :: Int16 -> Int #

peekElemOff :: Ptr Int16 -> Int -> IO Int16 #

pokeElemOff :: Ptr Int16 -> Int -> Int16 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int16 #

pokeByteOff :: Ptr b -> Int -> Int16 -> IO () #

peek :: Ptr Int16 -> IO Int16 #

poke :: Ptr Int16 -> Int16 -> IO () #

Integral Int16 # 
Instance details

Defined in NumHierarchy

Num Int16 # 
Instance details

Defined in NumHierarchy

Real Int16 # 
Instance details

Defined in NumHierarchy

Methods

toRational :: Int16 -> Rational #

Read Int16 # 
Instance details

Defined in Text.Read

Show Int16 # 
Instance details

Defined in Text.Show

Methods

showsPrec :: Int -> Int16 -> ShowS #

show :: Int16 -> String #

showList :: [Int16] -> ShowS #

data Int32 #

32-bit signed integer type

Instances

Instances details
Bits Int32 # 
Instance details

Defined in Data.Bits

Bounded Int32 # 
Instance details

Defined in Data.Enum

Enum Int32 # 
Instance details

Defined in Data.Enum

Eq Int32 # 
Instance details

Defined in Data.Eq

Methods

(==) :: Int32 -> Int32 -> Bool #

(/=) :: Int32 -> Int32 -> Bool #

Ix Int32 # 
Instance details

Defined in Data.Ix

Methods

range :: (Int32, Int32) -> [Int32] #

index :: (Int32, Int32) -> Int32 -> Int #

inRange :: (Int32, Int32) -> Int32 -> Bool #

rangeSize :: (Int32, Int32) -> Int #

Ord Int32 # 
Instance details

Defined in Data.Ord

Methods

compare :: Int32 -> Int32 -> Ordering #

(<) :: Int32 -> Int32 -> Bool #

(<=) :: Int32 -> Int32 -> Bool #

(>=) :: Int32 -> Int32 -> Bool #

(>) :: Int32 -> Int32 -> Bool #

max :: Int32 -> Int32 -> Int32 #

min :: Int32 -> Int32 -> Int32 #

Storable Int32 # 
Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Int32 -> Int #

alignment :: Int32 -> Int #

peekElemOff :: Ptr Int32 -> Int -> IO Int32 #

pokeElemOff :: Ptr Int32 -> Int -> Int32 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int32 #

pokeByteOff :: Ptr b -> Int -> Int32 -> IO () #

peek :: Ptr Int32 -> IO Int32 #

poke :: Ptr Int32 -> Int32 -> IO () #

Integral Int32 # 
Instance details

Defined in NumHierarchy

Num Int32 # 
Instance details

Defined in NumHierarchy

Real Int32 # 
Instance details

Defined in NumHierarchy

Methods

toRational :: Int32 -> Rational #

Read Int32 # 
Instance details

Defined in Text.Read

Show Int32 # 
Instance details

Defined in Text.Show

Methods

showsPrec :: Int -> Int32 -> ShowS #

show :: Int32 -> String #

showList :: [Int32] -> ShowS #

data Int64 #

64-bit signed integer type

Instances

Instances details
Bits Int64 # 
Instance details

Defined in Data.Bits

Bounded Int64 # 
Instance details

Defined in Data.Enum

Enum Int64 # 
Instance details

Defined in Data.Enum

Eq Int64 # 
Instance details

Defined in Data.Eq

Methods

(==) :: Int64 -> Int64 -> Bool #

(/=) :: Int64 -> Int64 -> Bool #

Ix Int64 # 
Instance details

Defined in Data.Ix

Methods

range :: (Int64, Int64) -> [Int64] #

index :: (Int64, Int64) -> Int64 -> Int #

inRange :: (Int64, Int64) -> Int64 -> Bool #

rangeSize :: (Int64, Int64) -> Int #

Ord Int64 # 
Instance details

Defined in Data.Ord

Methods

compare :: Int64 -> Int64 -> Ordering #

(<) :: Int64 -> Int64 -> Bool #

(<=) :: Int64 -> Int64 -> Bool #

(>=) :: Int64 -> Int64 -> Bool #

(>) :: Int64 -> Int64 -> Bool #

max :: Int64 -> Int64 -> Int64 #

min :: Int64 -> Int64 -> Int64 #

Storable Int64 # 
Instance details

Defined in Foreign.Storable

Methods

sizeOf :: Int64 -> Int #

alignment :: Int64 -> Int #

peekElemOff :: Ptr Int64 -> Int -> IO Int64 #

pokeElemOff :: Ptr Int64 -> Int -> Int64 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int64 #

pokeByteOff :: Ptr b -> Int -> Int64 -> IO () #

peek :: Ptr Int64 -> IO Int64 #

poke :: Ptr Int64 -> Int64 -> IO () #

Integral Int64 # 
Instance details

Defined in NumHierarchy

Num Int64 # 
Instance details

Defined in NumHierarchy

Real Int64 # 
Instance details

Defined in NumHierarchy

Methods

toRational :: Int64 -> Rational #

Read Int64 # 
Instance details

Defined in Text.Read

Show Int64 # 
Instance details

Defined in Text.Show

Methods

showsPrec :: Int -> Int64 -> ShowS #

show :: Int64 -> String #

showList :: [Int64] -> ShowS #