Math.Pow() bug?

  • Thread starter Thread starter Bo
  • Start date Start date
B

Bo

double v = -0.17665577379401631
double f = 0.016666666666666666
Math.Pow(v, f) returns me NaN.

What should I do now?
 
double v = -0.17665577379401631
double f = 0.016666666666666666
Math.Pow(v, f) returns me NaN.

What should I do now?

Read the documentation?
 
Bo said:
double v = -0.17665577379401631
double f = 0.016666666666666666
Math.Pow(v, f) returns me NaN.

What should I do now?

Use different numbers? f = 1/60, so you are asking for the 60th root
of v, or, what number when multiplied by itself 60 times will equal v.

But no number can, because, as 60 is even, any number raised to the 60th
power will be positive. In fact, Math.Pow is documented as refusing to
calculate the root of any negative number. The Calculator app that comes
with Windows operates the same way.

--
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
 
Bo said:
double v = -0.17665577379401631
double f = 0.016666666666666666
Math.Pow(v, f) returns me NaN.

What should I do now?

Create a Complex type?
 
Bo Dong said:

In MSDN, for Math.Pow. In particular, the line which states that if x
(v in your case) is < 0, and y (f in your case) is between 0 and 1
exclusive, the result is NaN.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top