packages feed

fast-digits 0.2.0.0 → 0.2.1.0

raw patch · 3 files changed

+16/−12 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

fast-digits.cabal view
@@ -1,5 +1,5 @@ name:                fast-digits-version:             0.2.0.0+version:             0.2.1.0 synopsis:            The fast library for integer-to-digits conversion. description:         Convert an integer to digits and back.                      Usually this library is twice as fast as "Data.Digits".
src/Data/FastDigits.hs view
@@ -1,7 +1,7 @@ {-| Module      : Data.FastDigits Description : The fast library for integer-to-digits conversion.-Copyright   : (c) Andrew Lelechenko, 2015+Copyright   : (c) Andrew Lelechenko, 2015-2016 License     : GPL-3 Maintainer  : andrew.lelechenko@gmail.com Stability   : experimental@@ -33,21 +33,23 @@ digitsNatural :: GmpLimb# -> BigNat -> [Word] digitsNatural base = f   where-    f n = if n == zeroBigNat-      then []-      else let (# q, r #) = n `quotRemBigNatWord` base in W# r : f q+    f n+      | isZeroBigNat n = []+      | otherwise      = let (# q, r #) = n `quotRemBigNatWord` base in+                         W# r : f q  digitsWord :: Word# -> Word# -> [Word] digitsWord 2## = g   where     g :: Word# -> [Word]     g 0## = []-    g n = W# (n `and#` 1##) : g (n `uncheckedShiftRL#` 1#)+    g n   = W# (n `and#` 1##) : g (n `uncheckedShiftRL#` 1#) digitsWord base = f   where     f :: Word# -> [Word]     f 0## = []-    f n = let (# q, r #) = n `quotRemWord#` base in W# r : f q+    f n   = let (# q, r #) = n `quotRemWord#` base in+            W# r : f q  -- | For a given base and expected length of list of digits --   return the list of digits and padding till expected length.@@ -56,16 +58,16 @@   where     g :: Word# -> (# [Word], Word# #)     g 0## = (# [], power #)-    g n = (# W# (n `and#` 1##) : fq, lq `minusWord#` 1## #)+    g n   = (# W# (n `and#` 1##) : fq, lq `minusWord#` 1## #)       where         (# fq, lq #) = g (n `uncheckedShiftRL#` 1#) digitsWordL base power = f   where     f :: Word# -> (# [Word], Word# #)     f 0## = (# [], power #)-    f n = (# W# r : fq, lq `minusWord#` 1## #)+    f n   = (# W# r : fq, lq `minusWord#` 1## #)       where-        (# q, r #) = n `quotRemWord#` base+        (#  q,  r #) = n `quotRemWord#` base         (# fq, lq #) = f q  -- | For a given base, power and precalculated base^power@@ -75,7 +77,7 @@   where     f :: BigNat -> [Word]     f n = let (# q, r #) = n `quotRemBigNatWord` poweredBase in-      if q == zeroBigNat+      if isZeroBigNat q         then digitsWord base r         else let (# fr, lr #) = digitsWordL base power r in           fr ++ replicate (I# (unsafeCoerce# lr)) 0 ++ f q
src/Data/FastDigits/Internal.hs view
@@ -1,6 +1,6 @@ {-| Module      : Data.FastDigits.Internal-Copyright   : (c) Andrew Lelechenko, 2015+Copyright   : (c) Andrew Lelechenko, 2015-2016 License     : GPL-3 Maintainer  : andrew.lelechenko@gmail.com Stability   : experimental@@ -21,6 +21,8 @@   ) where  import GHC.Exts++#include "MachDeps.h"  -- | Take an integer base and return (pow, base^pow), --   where base^pow <= maxBound and pow is as large as possible.