Based on ideas from the paper "The Ins and Outs of Solving Quadratic Equations with Floating-Point Arithmetic" (Frédéric Goualard, 2023) Could still be improved further, but I think this is acceptable for now.