| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Unwitch.Convert.Int32
Contents
Description
Conversions from Int32.
Synopsis
- toInt8 :: Int32 -> Maybe Int8
- toInt16 :: Int32 -> Maybe Int16
- toInt64 :: Int32 -> Int64
- toInt :: Int32 -> Int
- toInteger :: Int32 -> Integer
- toWord8 :: Int32 -> Maybe Word8
- toWord16 :: Int32 -> Maybe Word16
- toWord32 :: Int32 -> Maybe Word32
- toWord64 :: Int32 -> Maybe Word64
- toWord :: Int32 -> Maybe Word
- toNatural :: Int32 -> Either Overflows Natural
- toFloat :: Int32 -> Either Overflows Float
- toDouble :: Int32 -> Double
- toCInt :: Int32 -> CInt
- toInt8# :: Int32 -> (# Int8 | (# #) #)
- toInt16# :: Int32 -> (# Int16 | (# #) #)
- toInt# :: Int32 -> (# Int | (# #) #)
- toWord8# :: Int32 -> (# Word8 | (# #) #)
- toWord16# :: Int32 -> (# Word16 | (# #) #)
- toWord32# :: Int32 -> (# Word32 | (# #) #)
- toWord64# :: Int32 -> (# Word64 | (# #) #)
- toWord# :: Int32 -> (# Word | (# #) #)
- toNatural# :: Int32 -> (# Overflows | Natural #)
- toFloat# :: Int32 -> (# Overflows | Float #)
Conversions
toInt :: Int32 -> Int Source #
Total conversion — GHC implements Int using the primitive type
Int#, whose size equals the MachDeps.h constant
WORD_SIZE_IN_BITS (32 on 32-bit platforms, 64 on 64-bit).
Since Int# is always at least 32 bits wide, every Int32 value
fits without loss.
See: GHC.Prim ("Int32 always fits in Int (Int is at least 32 bits)") and Data.Int ("A fixed-precision integer type with at least the range [-2^29 .. 2^29-1]").
toFloat :: Int32 -> Either Overflows Float Source #
Checked conversion, fails if outside exact float integer range (+-16777215).
Unboxed conversions
These use GHC unboxed types and unboxed sums for zero-allocation
failure handling. Requires the MagicHash, UnboxedSums and
UnboxedTuples language extensions.
See the GHC manual on unboxed types.
toWord8# :: Int32 -> (# Word8 | (# #) #) Source #
Signed->unsigned narrow, roundtrip via Word# back to Int#