Math/sqrt problem!

Second thread of the day, it’s rainin noobfish.

Buteh, I sat down to creat a small app to calculate X in order to solve 2nd grade equations.

So, in order to manage this I had to translate "x = -p/2 ± sqrt((p/2)^2 - q), right?

And!
Everything works fine until I reach the step when I must perform equations with -p/2 and sqrt((p/2)^2 - q).

Adding and/or subtracting with these numbers causes Flash to return NaN. Why does it do this to me?