|
|
1.1 root 1: /*
2: * Square root function.
3: */
4: #include <math.h>
5:
6: #if EMU87
7: #include "emumath.h"
8: #endif
9:
10: double
11: sqrt(x)
12: double x;
13: {
14: double s;
15: int i;
16: register int n;
17:
18: if (x < 0.0) {
19: errno = EDOM;
20: return (0.0);
21: }
22: if (x == 0.)
23: return(0.);
24: n = L2L2P;
25: /* The assignment in the following line is to avoid compiler bug. */
26: s = frexp(x, &i);
27: s = ldexp(1.0, i/2);
28: do {
29: s = (s + x/s) / 2.0;
30: } while (--n);
31: return (s);
32: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.