I wrote a code snippet to execute a quadratic equation:
function quadratic($a,$b,$c) { $mb = $b - ($b*2); $bs = $b * $b; $fac = ($a * $c) * 4; $ans1 = ($mb + sqrt(($bs - $fac))) / (2 * $a); $ans2 = ($mb - sqrt(($bs - $fac))) / (2 * $a); echo ("Your <b>+</b> value is: " . $ans1 . "<br />"); echo ("Your <b>-</b> value is: " . $ans2); }
The problem is that if, for example, a = 2, b = 4, c = 8, both responses are output as NAN. Any ideas on how to fix this to get the actual pin number?
source share