使用可选的小数点浮动到字符串

时间:2015-12-08 12:24:58

标签: haskell numeric

我希望以下代码输出123but instead it prints 123.0

import Numeric
main = putStrLn $ showFFloat Nothing 123 ""

showFFloat被破坏了,还是我误读了documentation

我希望这种行为只来自showFFloatAlt

1 个答案:

答案 0 :(得分:2)

我期待那个结果。 '全精度'似乎包括最低限度的不确定性。从123开始,人们无法知道它是否已被舍入,从123.0可以。使用Just 0代替Nothing应符合您的期望。

相关问题