File:  [MW Coherent from dump] / coherent / b / lib / libm / sqrt.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:35 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * Square root function.
 */
#include <math.h>

#if	EMU87
#include "emumath.h"
#endif

double
sqrt(x)
double x;
{
	double s;
	int i;
	register int n;

	if (x < 0.0) {
		errno = EDOM;
		return (0.0);
	}
	if (x == 0.)
		return(0.);
	n = L2L2P;
	/* The assignment in the following line is to avoid compiler bug. */
	s = frexp(x, &i);
	s = ldexp(1.0, i/2);
	do {
		s = (s + x/s) / 2.0;
	} while (--n);
	return (s);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.