hex package:ghci-hexcalc

Hexadecimal formatting with maximum-bit length
Basic type
>>> 255 :: Hex
0x0000_0000_0000_00ff
Hexadecimal formatting with 16-bit length
Convert Hex to Double type
>>> hex2double 0x40091eb851eb851f
3.14
Convert Hex to Float type
>>> hex2float 0x3fc00000
1.5
Hexadecimal formatting with 32-bit length
Hexadecimal formatting with 64-bit length
Hexadecimal formatting with 8-bit length
Number sequence. [hexBitSeq-1, hexBitSeq-2, .. 0]
Bit size of Hex type. It's 64 on x86_64.
Number sequence. [hexByteSeq-1, hexByteSeq-2, .. 0]
Byte size of Hex type. It's 8 of x86_64.
Hexadecimal formatting with N-bit length
Hexadecimal formatting for pair of (length,Hex)
>>> (8,254) .@hexSized
"0xfe"
GHCi as a Hex Calculator interactive This package defines operations for an interactive hex-caluclator using GHCi. This is a simple and casual interactive tool like Perl and Excel for daily work.
This module defines operations for an interactive hex-caluclator using GHCi. This is a simple and casual interactive tool like Perl and Excel for daily work. Interactive oriented features:
  • Short-named operators and functions
  • Show values in hexadecimal format by default
  • Suppress type annotation of numeric literals by type inference
  • Postfix-notation available
  • Highlight available
Example of use:
ghci> (1 .<< 16) .| 0xf .& 3
0x0000_0000_0001_0003
ghci> 0xff .@dec
"255"
See also web page.
Convert Double to Hex type
>>> double2hex 1.0
0x3ff0_0000_0000_0000
Convert Float to Hex type
>>> float2hex 1.0
0x0000_0000_3f80_0000
Input hexadecimal string and convert to Hex type It reads only hexadecimal characters, [0-9a-fA-F]. That is, other characters, such as ',',:,-, are ignored. It is useful for reading from various command output, such as od, hexdump and etc.
ghci> inputRawHexIO
ff aa  (your input)
ghci>x = it
ghci>x
0x0000_0000_0000_ffaa
ghci> inputRawHexIO
0123:abcd:ffff  (your input)
ghci>x = it
ghci>x
0x0000_0123_abcd_ffff