本文介绍了如何在F#中获得多维数据集根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在F#中获得多维数据集根.但这是我的问题.
I tried to get the cube root in F#. But here is my problem.
let x5 = ((float 64) ** (1.0/3.0));;
val x5 : float = 4.0
int x5;; //expected 4
val it : int = 3
结果应为4,而不是3.
The result should be 4, not 3.
怎么了?
推荐答案
没什么错,问题是x5的值比4.0 小.您可能会清楚地看到使用fsi可以节省多少:
Nothing is wrong, the thing is that the value of your x5 is a bit less, than 4.0.You may explicitly see how much less using fsi:
let x5 = ((float 64) ** (1.0/3.0))
let err = 4.0 - x5;;
val x5 : float = 4.0
val err : float = 4.440892099e-16
这篇关于如何在F#中获得多维数据集根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!