| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Unwitch.Convert.Word32
Contents
Description
Conversions from Word32.
Synopsis
- toWord8 :: Word32 -> Maybe Word8
- toWord16 :: Word32 -> Maybe Word16
- toWord64 :: Word32 -> Word64
- toWord :: Word32 -> Maybe Word
- toNatural :: Word32 -> Natural
- toInt8 :: Word32 -> Maybe Int8
- toInt16 :: Word32 -> Maybe Int16
- toInt32 :: Word32 -> Maybe Int32
- toInt64 :: Word32 -> Int64
- toInt :: Word32 -> Maybe Int
- toInteger :: Word32 -> Integer
- toFloat :: Word32 -> Either Overflows Float
- toDouble :: Word32 -> Double
- toCInt :: Word32 -> Maybe CInt
- toWord8# :: Word32 -> (# Word8 | (# #) #)
- toWord16# :: Word32 -> (# Word16 | (# #) #)
- toWord# :: Word32 -> (# Word | (# #) #)
- toInt8# :: Word32 -> (# Int8 | (# #) #)
- toInt16# :: Word32 -> (# Int16 | (# #) #)
- toInt32# :: Word32 -> (# Int32 | (# #) #)
- toInt# :: Word32 -> (# Int | (# #) #)
- toFloat# :: Word32 -> (# Overflows | Float #)
Conversions
toFloat :: Word32 -> Either Overflows Float Source #
Checked conversion, fails with Overflow if outside exact float integer range.
toCInt :: Word32 -> Maybe CInt Source #
Narrowing conversion via Int32, fails if outside Int32 range.
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.
toWord# :: Word32 -> (# Word | (# #) #) Source #
Word32 always fits in Word (Word is at least 32 bits)
toInt8# :: Word32 -> (# Int8 | (# #) #) Source #
Unsigned->signed, source fits in Int#, roundtrip at Int#
toInt16# :: Word32 -> (# Int16 | (# #) #) Source #
Unsigned->signed, source fits in Int#, roundtrip at Int#