@@ -81,17 +81,17 @@ formatRealFloat fmt decs x
8181 " 0" -> " 0.0e0"
8282 [d] -> singleton d <> " .0e" <> show_e'
8383 (d: ds') -> singleton d <> singleton ' .' <> fromString ds' <> singleton ' e' <> show_e'
84- [] -> error " formatRealFloat/doFmt/Exponent: []"
84+ [] -> error " formatRealFloat/doFmt/Exponent/Nothing : []"
8585 Just dec ->
8686 let dec' = max dec 1 in
8787 case is of
8888 [0 ] -> " 0." <> fromText (T. replicate dec' " 0" ) <> " e0"
8989 _ ->
90- let
91- (ei, is') = roundTo (dec' + 1 ) is
92- (d : ds') = map i2d ( if ei > 0 then init is' else is')
93- in
94- singleton d <> singleton ' .' <> fromString ds' <> singleton ' e' <> decimal (e- 1 + ei)
90+ let (ei,is') = roundTo (dec' + 1 ) is
91+ is'' = map i2d ( if ei > 0 then init is' else is')
92+ in case is'' of
93+ [] -> error " formatRealFloat/doFmt/Exponent/Just: [] "
94+ (d : ds') -> singleton d <> singleton ' .' <> fromString ds' <> singleton ' e' <> decimal (e- 1 + ei)
9595 Fixed ->
9696 let
9797 mk0 ls = case ls of { " " -> " 0" ; _ -> fromString ls}
@@ -115,11 +115,11 @@ formatRealFloat fmt decs x
115115 in
116116 mk0 ls <> (if null rs then " " else singleton ' .' <> fromString rs)
117117 else
118- let
119- (ei, is') = roundTo dec' ( replicate ( - e) 0 ++ is)
120- d : ds' = map i2d ( if ei > 0 then is' else 0 : is')
121- in
122- singleton d <> (if null ds' then " " else singleton ' .' <> fromString ds')
118+ let (ei,is') = roundTo dec' ( replicate ( - e) 0 ++ is)
119+ is'' = map i2d ( if ei > 0 then is' else 0 : is' )
120+ in case is'' of
121+ [] -> error " formatRealFloat/doFmt/Fixed: [] "
122+ (d : ds') -> singleton d <> (if null ds' then " " else singleton ' .' <> fromString ds')
123123
124124
125125-- Based on "Printing Floating-Point Numbers Quickly and Accurately"
0 commit comments