I’m programming a game requiring evaluation of the function y = -x^2+49. When I type the following to my TI-84, I have to type it -(x)^2 + 49 or -x^2 + 49, and NOT (-x)^2 + 49. And here’s how I implemented it in C++
pp[i].death = -(j)^2 + 49; // Upside down hyperbola
I put a breakpoint to track the value, and it just doesn’t makes sense. My j is in the range [-7, +7] so it should return results in the range [0, 49]. But the C++ code gives me 52 or some random number that’s way off. Answers would be appreciated.
^is the bitwise xor operator, not exponentiation.Use
std::powinstead.