DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦d18e4f198⟧ TextFile

    Length: 275 (0x113)
    Types: TextFile
    Notes: UNIX file
    Names: »sqrt.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »libm/sqrt.c« 

TextFile

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

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

	if (x < 0.0) {
		errno = EDOM;
		return (0.0);
	}
	n = L2L2P;
	frexp(x, &i);
	s = ldexp(1.0, i/2);
	do {
		s = (s + x/s) / 2.0;
	} while (--n);
	return (s);
}