haskell 怎样限制小数的位数

showFFloat
ghci\u0026gt; showFFloat (Just 2) pi """3.14"显然那个多出来的 F 是 printf 里的 %f 的意思
那么你也可以 printf 啊
ghci\u0026gt; printf "%.2f" pi :: String -- printf 还支持 IO () 等其它类型"3.14" 【haskell 怎样限制小数的位数】 关于 ShowS 的详见 Text.Show


    推荐阅读