packages feed

crackNum 1.5 → 1.6

raw patch · 6 files changed

+65/−37 lines, 6 filesdep +FloatingHexdep ~basePVP ok

version bump matches the API change (PVP)

Dependencies added: FloatingHex

Dependency ranges changed: base

API changes (from Hackage documentation)

Files

CHANGES.md view
@@ -1,7 +1,14 @@ * Hackage: <http://hackage.haskell.org/package/crackNum> * GitHub:  <http://github.com/LeventErkok/crackNum/> -* Latest Hackage released version: 1.5, 2016-01-23+* Latest Hackage released version: 1.6, 2017-01-14++### 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 
Data/Numbers/CrackNum.hs view
@@ -31,7 +31,7 @@ import Numeric import Numeric.IEEE import Data.Binary.IEEE754-+import Data.Numbers.FloatingHex import Data.Numbers.CrackNum.Data import Data.Numbers.CrackNum.Utils @@ -100,9 +100,11 @@                 , "       Precision: " ++ show prec                 , "            Sign: " ++ if sign then "Negative" else "Positive"                 , "        Exponent: " ++ show expt ++ " (Stored: " ++ show stExpt ++ ", Bias: " ++ show bias ++ ")"+                , "       Hex-float: " ++ hexVal                 , "           Value: " ++ val                 ]              ++ [ "            Note: Representation for NaN's is not unique." | isNaNKind kind]+         (inds1, inds2, inds3) = case prec of                                   HP -> (hpInds1, hpInds2, hpInds3)                                   SP -> (spInds1, spInds2, spInds3)@@ -112,21 +114,30 @@                     SP -> [intVal `testBit` i | i <- startsAt 31]                     DP -> [intVal `testBit` i | i <- startsAt 63]             where startsAt n = [n, n-1 .. 0]-        val = case kind of-                Zero    False   -> "+0"-                Zero    True    -> "-0"-                Infty   False   -> "+Infinity"-                Infty   True    -> "-Infinity"-                SNaN            -> "NaN (Signaling)"-                QNaN            -> "NaN (Quietized)"-                Denormal        -> nval True  ++ " (DENORMAL)"-                Normal          -> nval False ++ " (NORMAL)"-        nval dn = (if sign then "-" else "+") ++ v-         where v = case prec of-                     HP -> showGFloat Nothing (spVal dn expt fracBits) ""-                     SP -> showGFloat Nothing (spVal dn expt fracBits) ""-                     DP -> showGFloat Nothing (dpVal dn expt fracBits) "" +        dup x = (x, x)++        (val, hexVal) = case kind of+                          Zero    False   -> dup "+0"+                          Zero    True    -> dup "-0"+                          Infty   False   -> dup "+Infinity"+                          Infty   True    -> dup "-Infinity"+                          SNaN            -> dup "NaN (Signaling)"+                          QNaN            -> dup "NaN (Quietized)"+                          Denormal        -> nval True  " (DENORMAL)"+                          Normal          -> nval False " (NORMAL)"++        nval dn tag = (s ++ vd ++ tag, s ++ vh)+         where s = if sign then "-" else "+"+               vd = case prec of+                      HP -> showGFloat Nothing (spVal dn expt fracBits) ""+                      SP -> showGFloat Nothing (spVal dn expt fracBits) ""+                      DP -> showGFloat Nothing (dpVal dn expt fracBits) ""+               vh = case prec of+                      HP -> showHFloat         (spVal dn expt fracBits) ""+                      SP -> showHFloat         (spVal dn expt fracBits) ""+                      DP -> showHFloat         (dpVal dn expt fracBits) ""+ -- | Show instance for FP instance Show FP where    show = displayFP@@ -187,12 +198,17 @@                                     , ("qnan",      (integerToFP SP 0x7fc00000, integerToFP DP 0x7ff8000000000000))                                     ]         mbF, mbD :: Maybe FP-        (mbF, mbD) = case (i `lookup` specials, reads i, reads i) of-                       (Just (f, d), _        , _        ) -> (Just f,         Just d)-                       (Nothing,     [(f, "")], [(d, "")]) -> (Just (floatToFP f),  Just (doubleToFP d))-                       (Nothing,     [(f, "")], _        ) -> (Just (floatToFP f),  Nothing)-                       (Nothing,     _,         [(d, "")]) -> (Nothing,        Just (doubleToFP d))-                       _                                   -> (Nothing,        Nothing)+        (mbF, mbD) = case (i `lookup` specials, rd i, rd i) of+                       (Just (f, d), _        , _  ) -> (Just f,         Just d)+                       (Nothing,     Just f, Just d) -> (Just (floatToFP f),  Just (doubleToFP d))+                       (Nothing,     Just f, _     ) -> (Just (floatToFP f),  Nothing)+                       (Nothing,     _,      Just d) -> (Nothing,        Just (doubleToFP d))+                       _                             -> (Nothing,        Nothing)++        rd :: (Read a, RealFloat a) => String -> Maybe a+        rd s = case reads s ++ [(v, "") | Just v <- [readHFloat s]] of+                 [(v, "")] -> Just v+                 _         -> Nothing  -- | Turn a Haskell float to the internal detailed FP representation floatToFP :: Float -> FP
Data/Numbers/CrackNum/Main.hs view
@@ -82,6 +82,7 @@               putStrLn "    Or, you can specify number of lanes with the -l option."               putStrLn "  - For \"toIEEE\" option (case doesn't matter):"               putStrLn "        - You can enter a number in decimal notation (like 2.3)"+              putStrLn "        - You can enter a number in hexadecimal notation (like 0x1.abcp+3)"               putStrLn "        - OR, enter one of the following:"               putStrLn "               * infinity, -infinity: Positive/Negative infinities"               putStrLn "               * nan, snan, qnan: Not-A-Number; signaling/quiet"
INSTALL view
@@ -1,3 +1,3 @@-The sbv library can be installed simply by issuing cabal install like this:+The crackNum library can be installed simply by issuing cabal install like this: -     cabal install IEEE754+     cabal install crackNum
README.md view
@@ -42,6 +42,7 @@         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@@ -65,6 +66,7 @@            Precision: SP                 Sign: Negative             Exponent: 121 (Stored: 248, Bias: 127)+           Hex-float: -0x1.015782p121                Value: -2.6723903e36 (NORMAL)     == Lane: 0 ==========================================                       3  2          1         0@@ -75,18 +77,20 @@            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)-         Value: -2300000.0 (NORMAL)+                  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)
crackNum.cabal view
@@ -1,5 +1,5 @@ Name:                crackNum-Version:             1.5+Version:             1.6 Synopsis:            Crack various integer, floating-point data formats Description:         Crack HP, SP and DP floats and 8, 16, 32, 64 bit words and integers.                      .@@ -11,7 +11,7 @@ Copyright:           Levent Erkok Category:            Tools Build-type:          Simple-Cabal-version:       >= 1.14+Cabal-version:       >= 1.10 Extra-Source-Files:  INSTALL, README.md, COPYRIGHT, CHANGES.md  source-repository head@@ -22,7 +22,7 @@    main-is      : Data/Numbers/CrackNum/Main.hs    ghc-options  : -Wall    default-language: Haskell2010-   build-depends: base >= 4 && < 5, ieee754, data-binary-ieee754+   build-depends: base >= 4 && < 5, ieee754, data-binary-ieee754, FloatingHex >= 0.2    other-modules: Data.Numbers.CrackNum                 , Data.Numbers.CrackNum.Utils                 , Data.Numbers.CrackNum.Data@@ -30,7 +30,7 @@ Library   ghc-options     : -Wall   default-language: Haskell2010-  Build-Depends   : base >= 4 && < 5, ieee754, data-binary-ieee754+  Build-Depends   : base >= 4 && < 5, ieee754, data-binary-ieee754, FloatingHex >= 0.2   Exposed-modules : Data.Numbers.CrackNum   other-modules   : Data.Numbers.CrackNum.Utils                   , Data.Numbers.CrackNum.Data