18 Data.Int
Date: 2010-07-20 13:11:00

[next] [prev] [prev-tail] [tail] [up]

## Chapter 18
Data.Int

module Data.Int (
Int, Int8, Int16, Int32, Int64
) where

### 18.1 Signed integer types

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 Data.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.

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 Prelude.minBound and Prelude.maxBound from the Prelude.Bounded class.

instance Bounded Int
instance Enum Int
instance Eq Int
instance Integral Int
instance Num Int
instance Ord Int
instance Read Int
instance Real Int
instance Show Int
instance Ix Int
instance Storable Int
instance Bits Int

data Int8

  8-bit signed integer type

instance Bounded Int8
instance Enum Int8
instance Eq Int8
instance Integral Int8
instance Num Int8
instance Ord Int8
instance Read Int8
instance Real Int8
instance Show Int8
instance Ix Int8
instance Storable Int8
instance Bits Int8

data Int16

  16-bit signed integer type

instance Bounded Int16
instance Enum Int16
instance Eq Int16
instance Integral Int16
instance Num Int16
instance Ord Int16
instance Read Int16
instance Real Int16
instance Show Int16
instance Ix Int16
instance Storable Int16
instance Bits Int16

data Int32

  32-bit signed integer type

instance Bounded Int32
instance Enum Int32
instance Eq Int32
instance Integral Int32
instance Num Int32
instance Ord Int32
instance Read Int32
instance Real Int32
instance Show Int32
instance Ix Int32
instance Storable Int32
instance Bits Int32

data Int64

  64-bit signed integer type

instance Bounded Int64
instance Enum Int64
instance Eq Int64
instance Integral Int64
instance Num Int64
instance Ord Int64
instance Read Int64
instance Real Int64
instance Show Int64
instance Ix Int64
instance Storable Int64
instance Bits Int64

[next] [prev] [prev-tail] [front] [up]