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

⟦bd4684cca⟧ TextFile

    Length: 578 (0x242)
    Types: TextFile
    Notes: UNIX file
    Names: »pow.c«

Derivation

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

TextFile

/*
 * Raise x to the power y.
 */
#include <math.h>

double
pow(x, y)
double x, y;
{
	double r;
	register unsigned s, i, e;

	s = 0;
	i = 0;
	if (x == 0.0) {
		if (y <= 0.0)
			errno = EDOM;
		return (0.0);
	}
	r = modf(y, &r);
	if (x < 0.0) {
		if (r != 0.0) {
			errno = EDOM;
			return (0.0);
		}
		x = -x;
		if (((int) y) & 1)
			s = 1;
	}
	if (y < 0.0) {
		y = -y;
		i = 1;
	}
	if (r!=0.0 || y>16384.0)
		r = _two(y*log10(x)*LOG10B2);
	else {
		r = 1.0;
		for (e=y; e; e>>=1) {
			if (e&01)
				r *= x;
			x *= x;
		}
	}
	if (i)
		r = 1/r;
	if (s)
		r = -r;
	return (r);
}