例如我可以使用 System.Math.Round((float),2)
将我的浮点数四舍五入到最接近的 2 个小数位,但无论如何在 F# 中我可以 向上取整 我的浮点数保留到小数点后两位?
谢谢
最佳答案
四舍五入的黑客解决方案
let round x d =
let rounded = Math.Round(x,d)
if rounded < x then x + Math.Pow(10,-d) else rounded
关于F# 向上舍入到特定的小数位数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15858408/