crackNum
Crack various integer and floatingpoint data formats
http://github.com/LeventErkok/CrackNum
Version on this page:  3.1 
LTS Haskell 22.40:  3.4 
Stackage Nightly 20241107:  3.14 
Latest on Hackage:  3.14 
BSD3Clause licensed by Levent Erkok
Maintained by [email protected]
This version can be pinned in stack with:
crackNum3.1@sha256:2fa562f83a19c732935b4771d9f23362ee28467b9aa92aac566c98f456a861f3,1234
Module documentation for 3.1
There are no documented modules for this package.
Depends on 8 packages(full list with versions):
Decode/Encode Integers, Words, and IEE754 Floats
On Hackage: http://hackage.haskell.org/package/crackNum
Example: Encode a decimal numer as a singleprecision IEEE754 number
$ crackNum fsp  2.3e6
Satisfiable. Model:
ENCODED = 2300000.0 :: Float
3 2 1 0
1 09876543 21098765432109876543210
S E8 S23
Binary layout: 1 10010100 00011000110000110000000
Hex layout: CA0C 6180
Precision: Single
Sign: Negative
Exponent: 21 (Stored: 148, Bias: 127)
Classification: FP_NORMAL
Binary: 0b1.0001100011000011p+21
Octal: 0o1.061414p+21
Decimal: 2300000.0
Hex: 0x2.3186p+20
Rounding mode: RNE: Round nearest ties to even.
Example: Decode a singleprecision IEEE754 number float from memorylayout
$ crackNum fsp 0xfc00 abc1
Satisfiable. Model:
DECODED = 2.6723903e36 :: Float
3 2 1 0
1 09876543 21098765432109876543210
S E8 S23
Binary layout: 1 11111000 00000001010101111000001
Hex layout: FC00 ABC1
Precision: Single
Sign: Negative
Exponent: 121 (Stored: 248, Bias: 127)
Classification: FP_NORMAL
Binary: 0b1.00000001010101111000001p+121
Octal: 0o2.00527404p+120
Decimal: 2.6723903e36
Hex: 0x2.02AF04p+120
$ crackNum fdp 0xfc00 abc1 7F80 0001
Example: Decode a custom (2+3) IEEE754 float from memorylayout
$ crackNum f2+3 0b10011
Satisfiable. Model:
DECODED = 0.75 :: FloatingPoint 2 3
4 32 10
S E2 S2
Binary layout: 1 00 11
Hex layout: 13
Precision: 2 exponent bits, 2 significand bits
Sign: Negative
Exponent: 0 (Subnormal, with fixed exponent value. Stored: 0, Bias: 1)
Classification: FP_SUBNORMAL
Binary: 0b1.1p1
Octal: 0o6p3
Decimal: 0.75
Hex: 0xcp4
Example: Encode an integer as a 7bit signed word
$ crackNum i7 12
Satisfiable. Model:
ENCODED = 12 :: IntN 7
654 3210
Binary layout: 000 1100
Hex layout: 0C
Type: Signed 7bit 2's complement integer
Sign: Positive
Binary: 0b1100
Octal: 0o14
Decimal: 12
Hex: 0xc
Usage info
Usage: crackNum value OR binary/hexpattern
i N Signed integer of Nbits
w N Unsigned integer of Nbits
f fp Floating point format fp
r rm Rounding mode to use. If not given, NearesttiestoEven.
h, ? help print help, with examples
v version print version info
Examples:
Encoding:
crackNum i4  2  encode as 4bit signed integer
crackNum w4 2  encode as 4bit unsigned integer
crackNum f3+4 2.5  encode as float with 3 bits exponent, 4 bits significand
crackNum f3+4 2.5 rRTZ  encode as above, but use RTZ rounding mode.
crackNum fbp 2.5  encode as a brainprecision float
crackNum fdp 2.5  encode as a doubleprecision float
Decoding:
crackNum i4 0b0110  decode as 4bit signed integer, from binary
crackNum w4 0xE  decode as 4bit unsigned integer, from hex
crackNum f3+4 0b0111001  decode as float with 3 bits exponent, 4 bits significand
crackNum fbp 0x000F  decode as a brainprecision float
crackNum fdp 0x8000000000000000  decode as a doubleprecision float
Notes:
 For encoding:
 Use  to separate your argument if it's a negative number.
 For floats: You can pass in NaN, Inf, 0, Inf etc as the argument, along with a decimal float.
 For decoding:
 Use hexadecimal (0x) or binary (0b) as input. Input must have one of these prefixes.
 You can use _, or space as a digit to improve readability for the pattern to be decoded
VIM users: You can use the https://github.com/LeventErkok/crackNum/blob/master/crackNum.vim file to
use CrackNum directly from VIM. Simply locate your cursor on the text to crack, and use the
command :CrackNum options
.
Changes

Latest Hackage released version: 3.1, 20210329
Version 3.1, 20210329
 Fix readme
Version 3.0, 20210329
 A complete rewrite, much simplified, and supporting arbitrary precision floats. Some of the old features and the library are dropped; so if you rely on the library nature of CrackNum, do not upgrade. For other users who merely use crackNum as an executable, the new version is strongly recommended.
Version 2.4, 20200905
 Changes required to compile cleanly with GHC 8.10.2
Version 2.3, 20181117
 Remove dependency on the ieee754 and reinterpretcast packages. The goal is to remove any FFI dependencies. We now define and export the required utilities directly in the CrackNum package.
Version 2.2, 20180901
 Instead of databinaryieee754, use reinterpretcast package. According to documents, the former is deprecated.
Version 2.1, 20180720
 Support for vieditor bindings. See the file “crackNum.vim” in the distribution or in the github repo You can put “so ~/.vim/crackNum.vim” (use the correct path!) and have vi crack numbers directly from inside your editor. Simply locate your cursor on a binary/hex stream of digits and type “:CrackNum”. See the “crackNum.vim” file for binding details.
Version 2.0, 20180317
 Import FloatingHex qualified to avoid GHC 8.4.1 compilation issue
Version 1.9, 20170122
 Minor fix to printing of +/0
Version 1.8, 20170115
 Bump up FloatingHex dependency to >0.4, this enables proper support for large doubles
Version 1.7, 20170114
 Fix a snafu in reading hexadecimal floats
Version 1.6, 20170114
 Add support for hexadecimalfloats. These now work both in toIEEE option as input, and also when printing the values out. (i.e., numbers of the form 0x1.abp3, etc.)
Version 1.5, 20160123
 Typo fixes; no functionality changes
Version 1.4, 20160117
 Fix NaN nomenclature: Screaming>Signaling
 Add an example to README.md
Version 1.3, 20150411
 Fix docs, github location
Version 1.2, 20150411
 Fix the constant qnan values for SP/DP
 Add conversions from float/double. Much easier to use.
 Better handling of nan values.
Version 1.1, 20150402
 Cleanup the API, examples etc.
Version 1.0, 20150401
 First implementation. Supports HP/SP/DP and signed/unsigned numbers in 8/16/32/64 bits.