[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:23 UTC 2010
The following commit has been merged in the master branch:
commit 59e8c8c7928d3eb74c2353e6c99bbda456b1410b
Author: John Goerzen <jgoerzen at complete.org>
Date: Sat Oct 14 02:04:55 2006 +0100
Add of MissingH.Size
diff --git a/MissingH/Size.hs b/MissingH/Size.hs
new file mode 100644
index 0000000..045842e
--- /dev/null
+++ b/MissingH/Size.hs
@@ -0,0 +1,66 @@
+{-
+Copyright (C) 2006 John Goerzen <jgoerzen at complete.org>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : MissingH.Size
+ Copyright : Copyright (C) 2006 John Goerzen
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John Goerzen <jgoerzen at complete.org>
+ Stability : provisional
+ Portability: portable
+
+Tools for rendering sizes
+
+Written by John Goerzen, jgoerzen\@complete.org -}
+
+module MissingH.Size (
+ )
+
+where
+import Data.List
+
+data SizeOpts = SizeOpts { base :: Integer,
+ powerIncr :: Integer,
+ firstPower :: Integer,
+ suffixes :: String}
+
+binaryOpts = SizeOpts {base = 2,
+ firstPower = 0,
+ suffixes = " KMGTPEZY",
+ powerIncr = 10}
+
+siOpts = SizeOpts {base = 10,
+ firstPower = -24,
+ suffixes = "yzafpnum kMGTPEZY",
+ powerIncr = 3}
+
+renderNum opts number =
+ return (retnum, suffix)
+ where exponent = (logBase (fromIntegral $ base opts) number)::Double
+ lastPower = (firstPower opts) +
+ (genericLength(suffixes opts) - 1) * (powerIncr opts)
+ usedexp =
+ if exponent < fromIntegral (firstPower opts)
+ then firstPower opts
+ else if exponent > fromIntegral lastPower
+ then lastPower
+ else (truncate exponent `div` (powerIncr opts)) * (powerIncr opts)
+ expidx = (usedexp - (firstPower opts)) `div` (base opts)
+ suffix = (suffixes opts !! (fromIntegral expidx))
+ retnum = number / ((fromIntegral (base opts) ** (fromIntegral usedexp)))
\ No newline at end of file
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list