| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Data.Word
Description
This module provides unsigned integer types of unspecified width (Word) and fixed widths (Word8, Word16, Word32 and Word64).
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 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 Word types defined here.
Right and left shifts by amounts greater than or equal to the width of the type result in a zero result. 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 Word is an unsigned integral type, with the same size as Int.
Instances
| Bits Word # | |
Defined in Data.Bits Methods (.&.) :: Word -> Word -> Word # (.|.) :: Word -> Word -> Word # complement :: Word -> Word # shift :: Word -> Int -> Word # rotate :: Word -> Int -> Word # setBit :: Word -> Int -> Word # clearBit :: Word -> Int -> Word # complementBit :: Word -> Int -> Word # testBit :: Word -> Int -> Bool # shiftL :: Word -> Int -> Word # shiftR :: Word -> Int -> Word # | |
| Bounded Word # | |
| Enum Word # | |
| Eq Word # | |
| Ix Word # | |
| Ord Word # | |
| Storable Word # | |
Defined in Foreign.Storable | |
| Integral Word # | |
| Num Word # | |
| Real Word # | |
Defined in NumHierarchy Methods toRational :: Word -> Rational # | |
| Read Word # | |
| Show Word # | |
8-bit unsigned integer type
Instances
| Bits Word8 # | |
Defined in Data.Bits Methods (.&.) :: Word8 -> Word8 -> Word8 # (.|.) :: Word8 -> Word8 -> Word8 # xor :: Word8 -> Word8 -> Word8 # complement :: Word8 -> Word8 # shift :: Word8 -> Int -> Word8 # rotate :: Word8 -> Int -> Word8 # setBit :: Word8 -> Int -> Word8 # clearBit :: Word8 -> Int -> Word8 # complementBit :: Word8 -> Int -> Word8 # testBit :: Word8 -> Int -> Bool # shiftL :: Word8 -> Int -> Word8 # shiftR :: Word8 -> Int -> Word8 # | |
| Bounded Word8 # | |
| Enum Word8 # | |
| Eq Word8 # | |
| Ix Word8 # | |
| Ord Word8 # | |
| Storable Word8 # | |
| Integral Word8 # | |
| Num Word8 # | |
| Real Word8 # | |
Defined in NumHierarchy Methods toRational :: Word8 -> Rational # | |
| Read Word8 # | |
| Show Word8 # | |
16-bit unsigned integer type
Instances
| Bits Word16 # | |
Defined in Data.Bits Methods (.&.) :: Word16 -> Word16 -> Word16 # (.|.) :: Word16 -> Word16 -> Word16 # xor :: Word16 -> Word16 -> Word16 # complement :: Word16 -> Word16 # shift :: Word16 -> Int -> Word16 # rotate :: Word16 -> Int -> Word16 # setBit :: Word16 -> Int -> Word16 # clearBit :: Word16 -> Int -> Word16 # complementBit :: Word16 -> Int -> Word16 # testBit :: Word16 -> Int -> Bool # shiftL :: Word16 -> Int -> Word16 # shiftR :: Word16 -> Int -> Word16 # | |
| Bounded Word16 # | |
| Enum Word16 # | |
Defined in Data.Enum | |
| Eq Word16 # | |
| Ix Word16 # | |
| Ord Word16 # | |
| Storable Word16 # | |
| Integral Word16 # | |
Defined in NumHierarchy | |
| Num Word16 # | |
| Real Word16 # | |
Defined in NumHierarchy Methods toRational :: Word16 -> Rational # | |
| Read Word16 # | |
| Show Word16 # | |
32-bit unsigned integer type
Instances
| Bits Word32 # | |
Defined in Data.Bits Methods (.&.) :: Word32 -> Word32 -> Word32 # (.|.) :: Word32 -> Word32 -> Word32 # xor :: Word32 -> Word32 -> Word32 # complement :: Word32 -> Word32 # shift :: Word32 -> Int -> Word32 # rotate :: Word32 -> Int -> Word32 # setBit :: Word32 -> Int -> Word32 # clearBit :: Word32 -> Int -> Word32 # complementBit :: Word32 -> Int -> Word32 # testBit :: Word32 -> Int -> Bool # shiftL :: Word32 -> Int -> Word32 # shiftR :: Word32 -> Int -> Word32 # | |
| Bounded Word32 # | |
| Enum Word32 # | |
Defined in Data.Enum | |
| Eq Word32 # | |
| Ix Word32 # | |
| Ord Word32 # | |
| Storable Word32 # | |
| Integral Word32 # | |
Defined in NumHierarchy | |
| Num Word32 # | |
| Real Word32 # | |
Defined in NumHierarchy Methods toRational :: Word32 -> Rational # | |
| Read Word32 # | |
| Show Word32 # | |
64-bit unsigned integer type
Instances
| Bits Word64 # | |
Defined in Data.Bits Methods (.&.) :: Word64 -> Word64 -> Word64 # (.|.) :: Word64 -> Word64 -> Word64 # xor :: Word64 -> Word64 -> Word64 # complement :: Word64 -> Word64 # shift :: Word64 -> Int -> Word64 # rotate :: Word64 -> Int -> Word64 # setBit :: Word64 -> Int -> Word64 # clearBit :: Word64 -> Int -> Word64 # complementBit :: Word64 -> Int -> Word64 # testBit :: Word64 -> Int -> Bool # shiftL :: Word64 -> Int -> Word64 # shiftR :: Word64 -> Int -> Word64 # | |
| Bounded Word64 # | |
| Enum Word64 # | |
Defined in Data.Enum | |
| Eq Word64 # | |
| Ix Word64 # | |
| Ord Word64 # | |
| Storable Word64 # | |
| Integral Word64 # | |
Defined in NumHierarchy | |
| Num Word64 # | |
| Real Word64 # | |
Defined in NumHierarchy Methods toRational :: Word64 -> Rational # | |
| Read Word64 # | |
| Show Word64 # | |