floatshow 0.1 → 0.1.1
raw patch · 2 files changed
+8/−50 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Text/FShow/RealFloat/Internals.hs +7/−49
- floatshow.cabal +1/−1
Text/FShow/RealFloat/Internals.hs view
@@ -85,56 +85,14 @@ -- Divide and conquer implementation -- generate the sequence of digits of a positive Integer integerToDigits :: Integer -> [Int]-integerToDigits nm- | nm < BASE = jhead (fromInteger nm) []- | otherwise = jprinth (jsplitf (BASE*BASE) nm) []- where-- -- Split n into digits in base p. We first split n into digits- -- in base p*p and then split each of these digits into two.- -- Note that the first 'digit' modulo p*p may have a leading zero- -- in base p that we need to drop - this is what jsplith takes care of.- -- jsplitb the handles the remaining digits.- jsplitf :: Integer -> Integer -> [Integer]- jsplitf p n- | p > n = [n]- | otherwise = jsplith p (jsplitf (p*p) n)-- jsplith :: Integer -> [Integer] -> [Integer]- jsplith p (n:ns) =- case n `quotRemInteger` p of- (# q, r #) ->- if q > 0 then q : r : jsplitb p ns- else r : jsplitb p ns- jsplith _ [] = error "jsplith: []"-- jsplitb :: Integer -> [Integer] -> [Integer]- jsplitb _ [] = []- jsplitb p (n:ns) = case n `quotRemInteger` p of- (# q, r #) ->- q : r : jsplitb p ns-- -- Convert a number that has been split into digits in base BASE^2- -- this includes a last splitting step and then conversion of digits- -- that all fit into a machine word.- jprinth :: [Integer] -> [Int] -> [Int]- jprinth (n:ns) cs =- case n `quotRemInteger` BASE of- (# q', r' #) ->- let q = fromInteger q'- r = fromInteger r'- in if q > 0 then jhead q $ jblock r $ jprintb ns cs- else jhead r $ jprintb ns cs- jprinth [] _ = error "jprinth []"-- jprintb :: [Integer] -> [Int] -> [Int]- jprintb [] cs = cs- jprintb (n:ns) cs = case n `quotRemInteger` BASE of- (# q', r' #) ->- let q = fromInteger q'- r = fromInteger r'- in jblock q $ jblock r $ jprintb ns cs+integerToDigits nm = integerToDigits' nm [] +integerToDigits' :: Integer -> [Int] -> [Int]+integerToDigits' nm ds+ | nm < BASE = jhead (fromInteger nm) ds+ | otherwise = case nm `quotRemInteger` BASE of+ (# q, r #) -> integerToDigits' q (jblock (fromInteger r) ds)+ where -- Convert an integer that fits into a machine word. Again, we have two -- functions, one that drops leading zeros (jhead) and one that doesn't -- (jblock)
floatshow.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 0.1+Version: 0.1.1 -- Constraint on the version of Cabal needed to build this package. Cabal-version: >=1.6