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?
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?
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
You can try Text.Printf.printf
. The %f
format should be what you want.
> import Text.Printf
> printf "%f" 0.0025 :: String
"0.0025"