From c2f005b53fe23b8fc711a5822c50bf856e99ce1e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 16 Feb 2017 19:22:54 +0100 Subject: Properly compute number of digits needed --- lib/Postdelay/TimeSpec/Utils.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Postdelay/TimeSpec/Utils.hs') 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 | otherwise = error "boundedNatural in undefined state" minDigits, maxDigits :: Extended Int - (minDigits, maxDigits) = ( fmap digits . I.lowerBound $ close bounds + (minDigits, maxDigits) = ( max 1 . fmap digits . I.lowerBound $ close bounds , fmap digits . I.upperBound $ close bounds ) where @@ -84,7 +84,7 @@ boundedNatural padded (I.intersection (0 <=..< PosInf) -> bounds) = do | otherwise = int digits :: n -> Int - digits = ceiling . (logBase 10 :: Double -> Double) . realToFrac . abs + digits = succ . floor . (logBase 10 :: Double -> Double) . realToFrac . abs boundedRational :: forall s m n. (Show n, RealFrac n, StringParser s m) => Bool -- ^ Require number to be padded with zeroes -- cgit v1.2.3