2 * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 * Author: Ceriel J.H. Jacobs
26 if (x
< 0) errno
= EDOM
;
30 if (x
> DBL_MAX
) return x
; /* for infinity */
32 val
= frexp(x
, &exponent
);
37 val
= ldexp(val
+ 1.0, exponent
/2 - 1);
38 /* was: val = (val + 1.0)/2.0; val = ldexp(val, exponent/2); */
39 for (exponent
= NITER
- 1; exponent
>= 0; exponent
--) {
40 val
= (val
+ x
/ val
) / 2.0;