summaryrefslogtreecommitdiff
path: root/lib/Postdelay/TimeSpec
diff options
context:
space:
mode:
authorGregor Kleen <aethoago@141.li>2017-02-16 19:22:54 +0100
committerGregor Kleen <aethoago@141.li>2017-02-16 19:22:54 +0100
commitc2f005b53fe23b8fc711a5822c50bf856e99ce1e (patch)
tree489ace6aff1a19d3e489a20862588508c93687cb /lib/Postdelay/TimeSpec
parent4a558948bbb4cb73587c52d23201b3e1da2ff0ca (diff)
downloadpostdelay-c2f005b53fe23b8fc711a5822c50bf856e99ce1e.tar
postdelay-c2f005b53fe23b8fc711a5822c50bf856e99ce1e.tar.gz
postdelay-c2f005b53fe23b8fc711a5822c50bf856e99ce1e.tar.bz2
postdelay-c2f005b53fe23b8fc711a5822c50bf856e99ce1e.tar.xz
postdelay-c2f005b53fe23b8fc711a5822c50bf856e99ce1e.zip
Properly compute number of digits needed
Diffstat (limited to 'lib/Postdelay/TimeSpec')
-rw-r--r--lib/Postdelay/TimeSpec/Utils.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/Postdelay/TimeSpec/Utils.hs b/lib/Postdelay/TimeSpec/Utils.hs
index c10fc4b..a8c7d4a 100644
--- a/lib/Postdelay/TimeSpec/Utils.hs
+++ b/lib/Postdelay/TimeSpec/Utils.hs
@@ -74,7 +74,7 @@ boundedNatural padded (I.intersection (0 <=..< PosInf) -> bounds) = do
74 | otherwise = error "boundedNatural in undefined state" 74 | otherwise = error "boundedNatural in undefined state"
75 75
76 minDigits, maxDigits :: Extended Int 76 minDigits, maxDigits :: Extended Int
77 (minDigits, maxDigits) = ( fmap digits . I.lowerBound $ close bounds 77 (minDigits, maxDigits) = ( max 1 . fmap digits . I.lowerBound $ close bounds
78 , fmap digits . I.upperBound $ close bounds 78 , fmap digits . I.upperBound $ close bounds
79 ) 79 )
80 where 80 where
@@ -84,7 +84,7 @@ boundedNatural padded (I.intersection (0 <=..< PosInf) -> bounds) = do
84 | otherwise = int 84 | otherwise = int
85 85
86 digits :: n -> Int 86 digits :: n -> Int
87 digits = ceiling . (logBase 10 :: Double -> Double) . realToFrac . abs 87 digits = succ . floor . (logBase 10 :: Double -> Double) . realToFrac . abs
88 88
89boundedRational :: forall s m n. (Show n, RealFrac n, StringParser s m) 89boundedRational :: forall s m n. (Show n, RealFrac n, StringParser s m)
90 => Bool -- ^ Require number to be padded with zeroes 90 => Bool -- ^ Require number to be padded with zeroes