AP_Math: better way of handling safe_sqrt()

better to test the result, than predict it
This commit is contained in:
Andrew Tridgell 2012-03-05 22:40:37 +11:00
parent ccada2e9c2
commit 8abbbe5713

View File

@ -24,10 +24,11 @@ float safe_asin(float v)
// real input should have been zero
float safe_sqrt(float v)
{
if (isnan(v) || v <= 0.0) {
return 0.0;
float ret = sqrt(v);
if (isnan(ret)) {
return 0;
}
return sqrt(v);
return ret;
}