@@ -76,12 +76,17 @@ parseNumPart =
7676 if T.null uncertainty
7777 then return $ str basenum
7878 else return $ str $ basenum <> "\xa0\xb1\xa0" <>
79− case T.break (=='.') basenum of
80− (_,ys)
81− | T.length ys <= 1 -> uncertainty
82− | otherwise -> "0." <>
83− T.replicate (T.length ys - 1 - T.length uncertainty) "0"
84− <> uncertainty
79+ let (_,ys) = T.break (=='.') basenum
80+ in case (T.length ys - 1, T.length uncertainty) of
81+ (0,_) -> uncertainty
82+ (x,y)
83+ | x > y -> "0." <> T.replicate (x - y) "0" <>
84+ T.dropWhileEnd (=='0') uncertainty
85+ | otherwise -> T.take (y - x) uncertainty <>
86+ case T.dropWhileEnd (=='0')
87+ (T.drop (y - x) uncertainty) of
88+ t | T.null t -> mempty
89+ | otherwise -> "." <> t
8590 parseComma = str "." <$ char ','
8691 parsePlusMinus = str "\xa0\xb1\xa0" <$ try (string "+-")
8792 parseParens =