fixedprec 0.2 → 0.2.1.0
raw patch · 2 files changed
+15/−6 lines, 2 filesdep +random
Dependencies added: random
Files
- Data/Number/FixedPrec.hs +11/−1
- fixedprec.cabal +4/−5
Data/Number/FixedPrec.hs view
@@ -28,6 +28,7 @@ ) where import Data.Ratio+import System.Random -- ---------------------------------------------------------------------- -- * Auxiliary functions@@ -72,7 +73,7 @@ -- ---------------------------------------------------------------------- -- ** Other general-purpose functions --- | Given positive numbers /b/ and /x/, return (/n/, /r/) such that+-- | Given positive /b/ > 1 and /x/ > 0, return (/n/, /r/) such that -- -- * /x/ = /r/ /b/[sup /n/] and -- @@ -542,3 +543,12 @@ lo = 10000000000 hi = 0.0000000001 +instance Precision e => Random (FixedPrec e) where+ randomR (lo, hi) g = (x, g1) where+ n = getprec x -- precision in decimal digits+ lo_n = floor (lo * 10^n)+ hi_n = floor (hi * 10^n)+ (x_n, g1) = randomR (lo_n, hi_n) g+ x = 0.1^n * fromInteger x_n+ + random = randomR (0, 1)
fixedprec.cabal view
@@ -1,14 +1,13 @@ Name: fixedprec--- don't forget to bump the "this" source tag-Version: 0.2+Version: 0.2.1.0 License: BSD3 cabal-version: >= 1.8 Build-type: Simple License-file: LICENSE-Copyright: (c) 2013 Peter Selinger+Copyright: Copyright (c) 2013 Peter Selinger Author: Peter Selinger Maintainer: selinger@mathstat.dal.ca-Stability: alpha+Stability: beta Category: Data, Math Synopsis: A fixed-precision real number type Description:@@ -21,7 +20,7 @@ Library Build-Depends:- base >= 3 && < 5+ base >= 3 && < 5, random ==1.0.* Exposed-modules: Data.Number.FixedPrec