Reputation: 243
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
The result should be 4, not 3.
What's wrong?
Upvotes: 0
Views: 782
Reputation: 10350
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
Upvotes: 3
Reputation: 4205
It looks like you may be looking at the wrong variable.
I checked it myself and an example is here:
(ideone is a free online compilation/execution service.)
Upvotes: 1