| 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
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: 2.1 |
| Enum Int # | Since: 2.1 |
| Eq Int | |
| Integral Int # | Since: 2.0.1 |
| Data Int # | Since: 4.0.0.0 |
| Num Int # | Since: 2.1 |
| Ord Int | |
| Read Int # | Since: 2.1 |
| Real Int # | Since: 2.0.1 |
| Show Int # | Since: 2.1 |
| Ix Int # | Since: 2.1 |
| FiniteBits Int # | Since: 4.6.0.0 |
| Bits Int # | Since: 2.1 |
| Storable Int # | Since: 2.1 |
| PrintfArg Int # | Since: 2.1 |
| Generic1 k (URec k Int) # | |
| Functor (URec * Int) # | |
| Foldable (URec * Int) # | |
| Traversable (URec * Int) # | |
| Eq (URec k Int p) # | |
| Ord (URec k Int p) # | |
| Show (URec k Int p) # | |
| Generic (URec k Int p) # | |
| data URec k Int # | Used for marking occurrences of Since: 4.9.0.0 |
| type Rep1 k (URec k Int) # | |
| type Rep (URec k Int p) # | |
8-bit signed integer type
Instances
| Bounded Int8 # | Since: 2.1 |
| Enum Int8 # | Since: 2.1 |
| Eq Int8 # | Since: 2.1 |
| Integral Int8 # | Since: 2.1 |
| Data Int8 # | Since: 4.0.0.0 |
| Num Int8 # | Since: 2.1 |
| Ord Int8 # | Since: 2.1 |
| Read Int8 # | Since: 2.1 |
| Real Int8 # | Since: 2.1 |
| Show Int8 # | Since: 2.1 |
| Ix Int8 # | Since: 2.1 |
| FiniteBits Int8 # | Since: 4.6.0.0 |
| Bits Int8 # | Since: 2.1 |
| Storable Int8 # | Since: 2.1 |
| PrintfArg Int8 # | Since: 2.1 |
16-bit signed integer type
Instances
| Bounded Int16 # | Since: 2.1 |
| Enum Int16 # | Since: 2.1 |
| Eq Int16 # | Since: 2.1 |
| Integral Int16 # | Since: 2.1 |
| Data Int16 # | Since: 4.0.0.0 |
| Num Int16 # | Since: 2.1 |
| Ord Int16 # | Since: 2.1 |
| Read Int16 # | Since: 2.1 |
| Real Int16 # | Since: 2.1 |
| Show Int16 # | Since: 2.1 |
| Ix Int16 # | Since: 2.1 |
| FiniteBits Int16 # | Since: 4.6.0.0 |
| Bits Int16 # | Since: 2.1 |
| Storable Int16 # | Since: 2.1 |
| PrintfArg Int16 # | Since: 2.1 |
32-bit signed integer type
Instances
| Bounded Int32 # | Since: 2.1 |
| Enum Int32 # | Since: 2.1 |
| Eq Int32 # | Since: 2.1 |
| Integral Int32 # | Since: 2.1 |
| Data Int32 # | Since: 4.0.0.0 |
| Num Int32 # | Since: 2.1 |
| Ord Int32 # | Since: 2.1 |
| Read Int32 # | Since: 2.1 |
| Real Int32 # | Since: 2.1 |
| Show Int32 # | Since: 2.1 |
| Ix Int32 # | Since: 2.1 |
| FiniteBits Int32 # | Since: 4.6.0.0 |
| Bits Int32 # | Since: 2.1 |
| Storable Int32 # | Since: 2.1 |
| PrintfArg Int32 # | Since: 2.1 |
64-bit signed integer type
Instances
| Bounded Int64 # | Since: 2.1 |
| Enum Int64 # | Since: 2.1 |
| Eq Int64 # | Since: 2.1 |
| Integral Int64 # | Since: 2.1 |
| Data Int64 # | Since: 4.0.0.0 |
| Num Int64 # | Since: 2.1 |
| Ord Int64 # | Since: 2.1 |
| Read Int64 # | Since: 2.1 |
| Real Int64 # | Since: 2.1 |
| Show Int64 # | Since: 2.1 |
| Ix Int64 # | Since: 2.1 |
| FiniteBits Int64 # | Since: 4.6.0.0 |
| Bits Int64 # | Since: 2.1 |
| Storable Int64 # | Since: 2.1 |
| PrintfArg Int64 # | Since: 2.1 |
Notes
- All arithmetic is performed modulo 2^n, where
nis 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
Enuminstances over a bounded type such asInt(see the section of the Haskell report dealing with arithmetic sequences) also hold for theEnuminstances over the variousInttypes 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 == 1in some C implementations.