0

I'm doing my homework in C++ Builder 6.

When I try to get a cubic root from variable X, I get this error:

result = std::pow(x, 1.0 / 3);

E2015 Ambiguity between "std::pow(double,double)" and "std::pow(float, int)"

What should i do to fix this? Or may be there is another way to get a cubic root?

CL.
  • 173,858
  • 17
  • 217
  • 259
  • 3
    Possible duplicate of [How can I obtain the cube root in C++?](https://stackoverflow.com/questions/18103769/how-can-i-obtain-the-cube-root-in-c) – Igor G Sep 07 '19 at 07:32

2 Answers2

0

The std::cbrt() is an inbuilt function in C++ STL which is used to calculate the cube root of number. It accepts a number as argument and returns the cube root of that number.

result = std::cbrt(x);

madnan
  • 161
  • 1
  • 7
0
  1. Declare variable x as double instead of float.
  2. std:pow(double(x), 1.0/3)
Igor G
  • 1,838
  • 6
  • 18