[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 15:11:29 UTC 2010
The following commit has been merged in the master branch:
commit dd88a18ceac1f30d236a0516a6dc66dda92dea68
Author: John Goerzen <jgoerzen at complete.org>
Date: Sat Oct 14 03:16:50 2006 +0100
Support negative numbers
diff --git a/MissingH/Size.hs b/MissingH/Size.hs
index ead4964..fe4ef13 100644
--- a/MissingH/Size.hs
+++ b/MissingH/Size.hs
@@ -50,10 +50,12 @@ siOpts = SizeOpts {base = 10,
suffixes = "yzafpnum kMGTPEZY",
powerIncr = 3}
-renderNum :: (Real a, Floating b, Ord b) => SizeOpts -> a -> (b, Char)
+renderNum :: (Ord a, Real a, Floating b, Ord b) => SizeOpts -> a -> (b, Char)
renderNum opts 0 = (0, snd $ renderNum opts 1)
-renderNum opts inpnumber =
- (retnum, suffix)
+renderNum opts inpnumber
+ | inpnumber < 0 =
+ (posres * (-1), possuf)
+ | otherwise = (retnum, suffix)
where number = fromRational . toRational $ inpnumber
incrList = map idx2pwr [0..length (suffixes opts) - 1]
incrIdxList = zip incrList [0..]
@@ -63,6 +65,7 @@ renderNum opts inpnumber =
(usedexp, expidx) =
case find finderfunc (reverse incrIdxList) of
Just x -> x
- Nothing -> head incrIdxList
+ Nothing -> head incrIdxList -- If not found, it's smaller than the first
suffix = (suffixes opts !! (fromIntegral expidx))
retnum = number / ((fromIntegral (base opts) ** (fromIntegral usedexp)))
+ (posres, possuf) = renderNum opts (inpnumber * (-1))
\ No newline at end of file
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list