Reputation: 5949
How to make Haskell show Fractional
values without exponent part preserving leading zeros?
For example, command show 0.0025
outputs "2.5e-3"
. Is there a way to redefine this behavior?
Upvotes: 1
Views: 113
Reputation: 4326
I tested first answer in this question , and it works
import Numeric
main = do
putStrLn (showFFloat (Just 4) 0.0025 "")
Numeric module: https://hackage.haskell.org/package/base-4.14.0.0/docs/Numeric.html
Upvotes: 4
Reputation: 116139
You can try Text.Printf.printf
. The %f
format should be what you want.
> import Text.Printf
> printf "%f" 0.0025 :: String
"0.0025"
Upvotes: 3