unwitch-3.0.0: converts between primitives
Safe HaskellNone
LanguageHaskell2010

Unwitch.Convert.Int64

Description

Conversions from Int64.

Synopsis

Conversions

toNatural :: Int64 -> Either Overflows Natural Source #

Signed-to-unsigned conversion, returns Left Underflow for negative values.

toFloat :: Int64 -> Either Overflows Float Source #

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

toDouble :: Int64 -> Either Overflows Double Source #

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

toCInt :: Int64 -> 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.

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

Narrow through Int#, compare at Int64#

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

Signed narrowing via Int64# comparison

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

Signed narrowing via Int64# comparison

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

Roundtrip check at Int64# level for platform safety

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

Signed->unsigned narrow via Int64# comparison

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

Signed->unsigned narrow via Int64# comparison

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

Signed->unsigned narrow via Int64# comparison

toWord64# :: Int64 -> (# Word64 | (# #) #) Source #

Signed->unsigned, check non-negative at Int64# level

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

Signed->unsigned, check non-negative at Int64# then roundtrip

toNatural# :: Int64 -> (# Overflows | Natural #) Source #

Check non-negative at Int64# level, construct NS

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

Bounds-checked float conversion via Int#

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

Bounds-checked double conversion via Int#