In a Python geometric algorithm I am developing I need the roots of a quadratic equation, with integer coefficients, rounded to the nearest integer; n.5 must be rounded upward. I need an exact result, not some approximation. (The reason is that these roots are used in if/else statements, and if the result is not exact the wrong path is chosen, and the algorithm fails catastrophically.) The calculation is performed millions of times, therefore speed is important.
In Python I have at my disposal integers of unlimited size, an integer division rounded downward to the nearest integer, and an isqrt(n) function that returns the square root rounded downward to the nearest integer.
I find no practical solution. Can someone help me?
To avoid misunderstanding, the result must always be exact.