Bug in the POW function?

When i call the pow function with the following conditions i get different results

  1. pow( x, 20.0f );
  2. pow( x, y );

where y = 20.0f.
x is a float as well.

Can anybody let me know whether they have encountered similar problems?
Or am i doing something wrong here?

maybe you should use the powf function?

What is the difference? Please post the smallest possible self-contained .cu file that repros the problem you’re seeing.

Paulius

I had a problem as below;

when pow function is called with 2.0 as first parameter and an integer type casted to double as second parameter, the resultant value is not correct.

Code snippet is as below;

int lp = 0;

int l = 11;

lp = (int)pow(2.0,(double)l);

From above, the value of lp comes as 1023. The expected value is 1024.

I am using Cuda 2.2.

I get correct result, if i modify the line as below;

lp = (int)pow(2.0,l); // no type cast to double

What hardware are you using? If you are using double-precision hardware, are you using the compiler flag to target sm_13?