unwitch-3.0.0: converts between primitives
Safe HaskellNone
LanguageHaskell2010

Unwitch.Convert.Word

Description

Conversions from Word.

Synopsis

Conversions

toFloat :: Word -> Either Overflows Float Source #

Checked conversion, fails if outside exact float integer range (+-16777215).

toDouble :: Word -> Either Overflows Double Source #

Checked conversion, fails if outside exact double integer range (+-9007199254740991).

toCInt :: Word -> 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# :: Word -> (# Word8 | (# #) #) Source #

Unsigned narrowing, roundtrip at Word#

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

Unsigned narrowing, roundtrip at Word#

toWord32# :: Word -> (# Word32 | (# #) #) Source #

Unsigned narrowing, roundtrip at Word#

toInt8# :: Word -> (# Int8 | (# #) #) Source #

Check upper bound for signed target

toInt16# :: Word -> (# Int16 | (# #) #) Source #

Check upper bound for signed target

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

Check upper bound for signed target

toInt64# :: Word -> (# Int64 | (# #) #) Source #

Check high bit not set for Int64

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

Check high bit not set for Int

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

Bounds-checked float conversion

toDouble# :: Word -> (# Overflows | Double #) Source #

Bounds-checked double conversion