When I try to take the N th root of a small number using C# I get a wrong number.
For example, when I try to take the third root of 1.07, I get 1, which is clearly not true.
Here is the exact code I am using to get the third root.
MessageBox.Show(Math.Pow(1.07,(1/3)).toString());
How do I solve this problem?
I would guess that this is a floating point arithmetic issue, but I don't know how to handle it.
It’s actually an integer division problem. 1/3 is evaluated as integers with the result of the division being 0. Thus you are really taking 1.07 to the 0th power which is 1.
– tvanfosson10 октября 2009, 02:06