cdornan / fmt

New formatting library
BSD 3-Clause "New" or "Revised" License
56 stars 6 forks source link

`floatF` handles negative numbers incorrectly #36

Closed kana-sama closed 3 years ago

kana-sama commented 3 years ago
floatF 1.2 = "1.2"
floatF 12.2 = "12.2"

but

floatF (-1.2) = "-1.2e0"
floatF (-12.2) = "-1.22e1"

So I think floatF should be defined something like

floatF :: Real a => a -> Builder
floatF a | d < 0 = "-" <> floatF (-d)
-- ... rest of definition
cdornan commented 3 years ago

fixed by e0e1e98dfe35486d6f1ea1b2389bd4af4d93914c