fork download
  1. #include<iostream> // std::cout, std::endl
  2. #include<cstdio> // getchar
  3. #include<cmath> // std::pow, std::abs, std::signbit
  4.  
  5. float f(float x)
  6. {
  7. float result = -5.0f * x * x - 2.0f * x + 1.0f;
  8. float intermediate = std::pow(std::abs(result),1.0f/3.0f);
  9. if (std::signbit(result))
  10. return -intermediate; // Negate if 'result' is negative
  11. return intermediate;
  12. }
  13. int main()
  14. {
  15. std::cout << f(-1) << std::endl;
  16. getchar();
  17. return 0;
  18. }
Success #stdin #stdout 0s 15240KB
stdin
stdout
-1.25992