src/genquad.py
def general_quadratic(a: float, b: float, c: float) -> (float, float):
    "Computes the general quadratic equation."

    if not (isinstance(a, (int, float)) and
        isinstance(b, (int, float)) and
        isinstance(c, (int, float))):
        raise ValueError("passed non-floats")

    a = float(a)
    b = float(b)
    c = float(c)

    if abs(a) < 0.001:
        raise NotQuadratic()
    
    try:
        if (4 * a * c) > (b**2):
            raise ImaginaryResult()
        discriminant = sqrt(b**2 - (4 * a * c))
        numerator_1 = (-1 * b) - discriminant
        numerator_2 = (-1 * b) + discriminant
        denominator = 2 * a
        return (numerator_1 / denominator, numerator_2 / denominator)
    
    except OverflowError:
        raise ValueError("numeric crash")
Computes the general quadratic equation.
Computes the general quadratic equation.
Computes the general quadratic equation .
def general_quadratic(a: float, b: float, c: float) -> (float, float):
    if not (isinstance(a, (int, float)) and
        isinstance(b, (int, float)) and
        isinstance(c, (int, float))):
        raise ValueError("passed non-floats")
    a = float(a)
    b = float(b)
    c = float(c)
    if abs(a) < 0.001:
        raise NotQuadratic()
    try:
        if (4 * a * c) > (b**2):
            raise ImaginaryResult()
        discriminant = sqrt(b**2 - (4 * a * c))
        numerator_1 = (-1 * b) - discriminant
        numerator_2 = (-1 * b) + discriminant
        denominator = 2 * a
        return (numerator_1 / denominator, numerator_2 / denominator)
    except OverflowError:
        raise ValueError("numeric crash")
def general_quadratic ( a : float , b : float , c : float ) -> ( float , float ) : if not ( isinstance ( a , ( int , float ) ) and isinstance ( b , ( int , float ) ) and isinstance ( c , ( int , float ) ) ) : raise ValueError ( "passed non-floats" ) a = float ( a ) b = float ( b ) c = float ( c ) if abs ( a ) < 0.001 : raise NotQuadratic ( ) try : if ( 4 * a * c ) > ( b ** 2 ) : raise ImaginaryResult ( ) discriminant = sqrt ( b ** 2 - ( 4 * a * c ) ) numerator_1 = ( - 1 * b ) - discriminant numerator_2 = ( - 1 * b ) + discriminant denominator = 2 * a return ( numerator_1 / denominator , numerator_2 / denominator ) except OverflowError : raise ValueError ( "numeric crash" )
Computes the general quadratic equation.
Computes the general quadratic equation .
"Computes the general quadratic equation."
a
float
b
float
c
float