01-18-2012, 08:53 AM
(This post was last modified: 01-18-2012, 10:47 AM by AceInfinity.)
You don't know about the square root methods in C++ or you're just having issues with it in any updated code so far?
What are you talking about C++ doesn't support Minus sign with a variable though???
Make sure your variable definitions have the "signed" attribute... and not "unsigned"
Edit: I may not be able to help with the equation, but I can help you with the coding if I know what you want to do. Been a while since I used that equation for anything, so I don't quite understand how it's used. But I can tell you how to get certain variables from that equation in code.
Hmm try this line instead of all the clutter you've got going on, i've put the formula all into one line:
pow from math.h takes a double as input as well, not int.
Can't test as I have no idea of what kind of valid numbers would go into the equation however. You're last bit of the equation seems to have been right, just not sure where that 1 came in when you had it in your code... If it's not working, just reply with what happens at runtime with this. Or provide me with some valid numbers that can be used for this equation that I can fool around with.
What are you talking about C++ doesn't support Minus sign with a variable though???
Make sure your variable definitions have the "signed" attribute... and not "unsigned"
Edit: I may not be able to help with the equation, but I can help you with the coding if I know what you want to do. Been a while since I used that equation for anything, so I don't quite understand how it's used. But I can tell you how to get certain variables from that equation in code.
Hmm try this line instead of all the clutter you've got going on, i've put the formula all into one line:
Code:
x = (-b + sqrt(pow(b, 2) - (4 * a * c))) / (2 * a);
pow from math.h takes a double as input as well, not int.
Can't test as I have no idea of what kind of valid numbers would go into the equation however. You're last bit of the equation seems to have been right, just not sure where that 1 came in when you had it in your code... If it's not working, just reply with what happens at runtime with this. Or provide me with some valid numbers that can be used for this equation that I can fool around with.