Hi everyone,
I recently posted a topic related with the int UNDERFLOW and OVERFLOW issues. After Reading the responses, I defined a long type value and calculated the determinant, I also put a Integer.MAX_VALUE and Integer.MIN_VALUE in order to avoid the error. The program is about to resolve the well-known Quadratic equation --> ax^2 + bx + c = 0
see My code above
1- d is a long type variable, and is the determinant
2- I checked it for int UNDERFLOW and OVERFLOW
3- If no exceptions were trhown, then a casting is done int calc = (int) d
4- After this an evaluation about the determinant values are carried on (the calc variable)
5- And this is were my problems really started about 2 days ago
The strange thing is: the program is evaluated through
JUnit test
Most of them passed, but the (1,0,-2025000000), has been given a totally weird answer and is in this point when despair came
How a determinant can give a value of -489934590 if its formula said (b * b) . (4 * a * c) being a = 1, b = 0, c = -2025000000
and to get the things worse, when I ran the JUnit test in this Ítem, with same values the answer was -45000, 45000
I was about to think JUnit was wrong, but I search on Internet for a Quadratic solution calculator, found one, gave the values (1,0,-2025000000) AND GUESS WHAT? those values -45000, 45000 were shinning on the screen
thanks in advance,