|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 578 (0x242)
Types: TextFile
Notes: UNIX file
Names: »pow.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦f4b8d8c84⟧ UNIX Filesystem
└─⟦this⟧ »libm/pow.c«
/*
* 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);
}