| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
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.
Documentation
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
| Bits Int # | |
| Bounded Int # | |
| Enum Int # | |
| Eq Int # | |
| Ix Int # | |
| Ord Int # | |
| Storable Int # | |
Defined in Foreign.Storable | |
| Integral Int # | |
| Num Int # | |
| Real Int # | |
Defined in NumHierarchy Methods toRational :: Int -> Rational # | |
| Read Int # | |
| Show Int # | |
8-bit signed integer type
Instances
| Bits Int8 # | |
Defined in Data.Bits Methods (.&.) :: 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 # shiftL :: Int8 -> Int -> Int8 # shiftR :: Int8 -> Int -> Int8 # | |
| Bounded Int8 # | |
| Enum Int8 # | |
| Eq Int8 # | |
| Ix Int8 # | |
| Ord Int8 # | |
| Storable Int8 # | |
Defined in Foreign.Storable | |
| Integral Int8 # | |
| Num Int8 # | |
| Real Int8 # | |
Defined in NumHierarchy Methods toRational :: Int8 -> Rational # | |
| Read Int8 # | |
| Show Int8 # | |
16-bit signed integer type
Instances
| Bits Int16 # | |
Defined in Data.Bits 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 # shiftL :: Int16 -> Int -> Int16 # shiftR :: Int16 -> Int -> Int16 # | |
| Bounded Int16 # | |
| Enum Int16 # | |
| Eq Int16 # | |
| Ix Int16 # | |
| Ord Int16 # | |
| Storable Int16 # | |
| Integral Int16 # | |
| Num Int16 # | |
| Real Int16 # | |
Defined in NumHierarchy Methods toRational :: Int16 -> Rational # | |
| Read Int16 # | |
| Show Int16 # | |
32-bit signed integer type
Instances
| Bits Int32 # | |
Defined in Data.Bits 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 # shiftL :: Int32 -> Int -> Int32 # shiftR :: Int32 -> Int -> Int32 # | |
| Bounded Int32 # | |
| Enum Int32 # | |
| Eq Int32 # | |
| Ix Int32 # | |
| Ord Int32 # | |
| Storable Int32 # | |
| Integral Int32 # | |
| Num Int32 # | |
| Real Int32 # | |
Defined in NumHierarchy Methods toRational :: Int32 -> Rational # | |
| Read Int32 # | |
| Show Int32 # | |
64-bit signed integer type
Instances
| Bits Int64 # | |
Defined in Data.Bits 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 # shiftL :: Int64 -> Int -> Int64 # shiftR :: Int64 -> Int -> Int64 # | |
| Bounded Int64 # | |
| Enum Int64 # | |
| Eq Int64 # | |
| Ix Int64 # | |
| Ord Int64 # | |
| Storable Int64 # | |
| Integral Int64 # | |
| Num Int64 # | |
| Real Int64 # | |
Defined in NumHierarchy Methods toRational :: Int64 -> Rational # | |
| Read Int64 # | |
| Show Int64 # | |