| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Common.Type.Integer
Documentation
Constructors
| I8 Int8 | |
| UI8 Word8 | |
| I16 Int16 | |
| UI16 Word16 | |
| I32 Int32 | |
| UI32 Word32 | |
| I64 Int64 | |
| UI64 Word64 | |
| IChar Int8 | |
| UIChar Word8 |
intValueToInt :: IntValue -> Int Source #
Converts an IntValue to a standard Haskell Int.
@args - v: The IntValue to convert.
@details
This function handles all IntValue constructors, converting them
to the system's native Int type. Note that converting large
64-bit values on a 32-bit system might cause overflow, though
this is rare in modern environments.
@return
The integer value as an Int.
fitInteger :: Integer -> IntValue Source #
Converts an arbitrary Integer to the smallest suitable IntValue.
@args - n: The Integer to compress.
@details
Similar to fromInt64 but works on arbitrary precision Integers.
It attempts to fit the value into I8UI8, then I16UI16, etc.
If the value exceeds the signed 64-bit range but fits in unsigned 64-bit,
it uses UI64.
@return
The optimized IntValue.
fromInt64 :: Int64 -> IntValue Source #
Converts an Int64 to the smallest suitable IntValue representation.
@args - n: The Int64 value to compress.
@details This function checks the bounds of the integer to determine the most compact storage format (I8, UI8, I16, etc.). It prioritizes signed representation for small positive numbers but will use unsigned types if it saves space (e.g., 200 fits in UI8 but requires I16).
@return
An IntValue wrapping the value in the smallest possible container.