C's pow function refuses to work with variable exponent

后端 未结 5 1479
遥遥无期
遥遥无期 2021-01-17 20:59

Let\'s say I have the following code snippet:

int i; double value;
for(i = 0; i < CONSTANT; i++) {
  value = (double)pow(2, i);
}

Trying

5条回答
  •  余生分开走
    2021-01-17 21:28

    http://www.cplusplus.com/reference/clibrary/cmath/pow/

    In C, only the version taking two double parameters exists with this name. The other overloads are only available in C++.

    It looks like you can't pass an int, so just make i a double and that should work.

提交回复
热议问题