unwitch-3.0.0: converts between primitives
Safe HaskellNone
LanguageHaskell2010

Unwitch.Convert.Word32

Description

Conversions from Word32.

Synopsis

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.

toWord8# :: Word32 -> (# Word8 | (# #) #) Source #

Unsigned narrowing, roundtrip at Word#

toWord16# :: Word32 -> (# Word16 | (# #) #) Source #

Unsigned narrowing, roundtrip at Word#

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#

toInt32# :: Word32 -> (# Int32 | (# #) #) Source #

Unsigned->signed, roundtrip at Int#

toInt# :: Word32 -> (# Int | (# #) #) Source #

Word32 fits in non-negative Int on all platforms, check via sign bit

toFloat# :: Word32 -> (# Overflows | Float #) Source #

Bounds-checked float conversion