Hello,
I saw this problem today.
I used to calculate this: varX = Math.Pow(varx, 1/3);
Everytime I get only an integer that is completly wrong!
But if I use this: varX = Math.Pow(varx, 0.333333);
Then the result is allright...
What is wrong with this function?
I can't express 1/3 as a double number cause it's endless.
Please help me...
Math.Pow can't handle fractions ?
5 Answers
Know the answer? Post it. Somebody with the same question will find it here.

FroglegRank #1,020 · 1.9K reputationPosted Mar 22, 2011, 4:29 AM EDT
1:
double dd = Math.Round(((double)1 / (double)3),5);
2: or
decimal dd = Decimal.Round((decimal)1 / (decimal)3,5);
varX = Math.Pow(varx, dd);
Sascha B122 reputationPosted Mar 22, 2011, 4:33 AM EDT
And it WORKS! O_o
It can't calculate with endless numbers, can it?
Many thanks
FroglegRank #1,020 · 1.9K reputationPosted Mar 22, 2011, 4:36 AM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 22, 2011, 5:20 AM EDT
1.0/3 or 1D/3
or decimal arithmetic with:
1M/3
As long as at least one operand is of type double or decimal, then this will avoid integer arithmetic from being used.
Sascha B122 reputationPosted Mar 22, 2011, 5:27 AM EDT
I think it is more "correctly" than Froglegs round workaround.
Thanks