| 14 | |
| 15 | #if __MWERKS__ > 0x2301 |
| 16 | extern inline float sqrtf(float x) |
| 17 | { |
| 18 | static const double _half = .5f; |
| 19 | static const double _three = 3.0f; |
| 20 | if (x > 0.0f) |
| 21 | { |
| 22 | double xd = (double)x; |
| 23 | double guess = __frsqrte(xd); // returns an approximation to |
| 24 | guess = _half * guess * (_three - guess * guess * xd); // now have 12 sig bits |
| 25 | guess = _half * guess * (_three - guess * guess * xd); // now have 24 sig bits |
| 26 | guess = _half * guess * (_three - guess * guess * xd); // now have 32 sig bits |
| 27 | return (float)(xd * guess); |
| 28 | } |
| 29 | else if (x < 0.0) |
| 30 | { |
| 31 | return NAN; |
| 32 | } |
| 33 | else if (isnan(x)) |
| 34 | { |
| 35 | return NAN; |
| 36 | } |
| 37 | else |
| 38 | { |
| 39 | return x; |
| 40 | } |
| 41 | } |
| 42 | #else |
| 43 | extern inline float sqrtf(float x) |
| 44 | { |
no outgoing calls
no test coverage detected