crackNum
Crack various integer, floating-point data formats
http://github.com/LeventErkok/CrackNum
Version on this page: | 2.3 |
LTS Haskell 22.39: | 3.4 |
Stackage Nightly 2024-10-29: | 3.14 |
Latest on Hackage: | 3.14 |
BSD-3-Clause licensed by Levent Erkok
Maintained by [email protected]
This version can be pinned in stack with:
crackNum-2.3@sha256:e75ed11406e550abd0bd06297c2cbe20e66cdac0764f7a5176b42c727aefed31,1451
Module documentation for 2.3
- Data
- Data.Numbers
Depends on 3 packages(full list with versions):
Used by 1 package in lts-13.19(full list with versions):
CrackNum: Decode/Encode IEE754 Numbers
CrackNum now comes with vim bindings, see http://github.com/LeventErkok/crackNum/blob/master/crackNum.vim
Command line options:
crackNum v2.3, (c) Levent Erkok. Released with a BSD3 license.
Usage: crackNum precision bit/hex-pattern
--hp 16 bit half precision
--sp 32 bit single precision
--dp 64 bit double precision
--sb 8 bit signed byte
--sw 16 bit signed word
--sd 32 bit signed double
--sq 64 bit signed quad
--ub 8 bit unsigned byte
--uw 16 bit unsigned word
--ud 32 bit unsigned double
--uq 64 bit unsigned quad
--toIEEE=n Convert from decimal to IEEE SP/DP formats.
-l n --lanes=n number of lanes
--vim output in vim friendly format
-h, -? --help print help, with examples
-v --version print version info
Examples:
crackNum --hp fc00
crackNum --sp fc00 abcd
crackNum --dp fc00 abc1 2345 6789
crackNum --sp 01111111110000000000000000000000
crackNum -l2 --hp 01111111110000000000000000000000
crackNum --sb 7f
crackNum --sp --toIEEE=-2.3e6
crackNum --dp --toIEEE=max
crackNum --dp --toIEEE=ulp
Notes:
- You can use hexadecimal or binary as input.
- You can use _,- or space as a digit to improve readability.
- You can give input for multiple lanes, we will guess the #of lanes for you.
Or, you can specify number of lanes with the -l option.
- For "toIEEE" option (case doesn't matter):
- You can enter a number in decimal notation (like 2.3)
- You can enter a number in hexadecimal notation (like 0x1.abcp+3)
- OR, enter one of the following:
* infinity, -infinity: Positive/Negative infinities
* nan, snan, qnan: Not-A-Number; signaling/quiet
* 0, -0: Both kinds of zeros
* max : The maximum finite positive value
* -max: The minimum finite negative value
* min : The minimum normal positive value
* -min: The maximum normal negative value
* epsilon: The smallest possible value x s.t. 1+x /= 1.
* ulp: The minimum subnormal value
Example: Decoding single-precision numbers on two lanes
$ crackNum --sp fc00 abc1 7F80 0001
== Lane: 1 ==========================================
3 2 1 0
1 09876543 21098765432109876543210
S ---E8--- ----------F23----------
Binary: 1 11111000 00000001010101111000001
Hex: FC00 ABC1
Precision: SP
Sign: Negative
Exponent: 121 (Stored: 248, Bias: 127)
Hex-float: -0x1.015782p121
Value: -2.6723903e36 (NORMAL)
== Lane: 0 ==========================================
3 2 1 0
1 09876543 21098765432109876543210
S ---E8--- ----------F23----------
Binary: 0 11111111 00000000000000000000001
Hex: 7F80 0001
Precision: SP
Sign: Positive
Exponent: 128 (Stored: 255, Bias: 127)
Hex-float: NaN (Signaling)
Value: NaN (Signaling)
Note: Representation for NaN's is not unique.
Example: Encoding a float as a IEEE754 single-precision bit-pattern
$ crackNum --sp --toIEEE=-2.3e6
3 2 1 0
1 09876543 21098765432109876543210
S ---E8--- ----------F23----------
Binary: 1 10010100 00011000110000110000000
Hex: CA0C 6180
Precision: SP
Sign: Negative
Exponent: 21 (Stored: 148, Bias: 127)
Hex-float: -0x1.18c3p21
Value: -2300000.0 (NORMAL)
Changes
-
Latest Hackage released version: 2.3, 2018-11-17
Version 2.3, 2018-11-17
- Remove dependency on the ieee754 and reinterpret-cast 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, 2018-09-01
- Instead of data-binary-ieee754, use reinterpret-cast package. According to documents, the former is deprecated.
Version 2.1, 2018-07-20
- Support for vi-editor 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, 2018-03-17
- Import FloatingHex qualified to avoid GHC 8.4.1 compilation issue
Version 1.9, 2017-01-22
- Minor fix to printing of +/-0
Version 1.8, 2017-01-15
- Bump up FloatingHex dependency to >0.4, this enables proper support for large doubles
Version 1.7, 2017-01-14
- Fix a snafu in reading hexadecimal floats
Version 1.6, 2017-01-14
- Add support for hexadecimal-floats. These now work both in toIEEE option as input, and also when printing the values out. (i.e., numbers of the form 0x1.abp-3, etc.)
Version 1.5, 2016-01-23
- Typo fixes; no functionality changes
Version 1.4, 2016-01-17
- Fix NaN nomenclature: Screaming->Signaling
- Add an example to README.md
Version 1.3, 2015-04-11
- Fix docs, github location
Version 1.2, 2015-04-11
- 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, 2015-04-02
- Clean-up the API, examples etc.
Version 1.0, 2015-04-01
- First implementation. Supports HP/SP/DP and signed/unsigned numbers in 8/16/32/64 bits.