double log(x) double x;
{ int e; #ifdef DEC short *q; #endif double y, z; double frexp(), ldexp(), polevl(), p1evl();
/* Test for domain */ if( x <= 0.0 )
{ if( x == 0.0 )
mtherr( fname, SING ); else
mtherr( fname, DOMAIN ); return( MINLOG );
}
/* separate mantissa from exponent */
#ifdef DEC
q = (short *)&x;
e = *q; /* short containing exponent */
e = ((e >> 7) & 0377) - 0200; /* the exponent */
*q &= 0177; /* strip exponent from x */
*q |= 040000; /* x now between 0.5 and 1 */ #endif
/* Note, frexp is used so that denormal numbers *willbehandledproperly.
*/ #ifdef IBMPC
x = frexp( x, &e ); /* q=(short*)&x; q+=3; e=*q; e=((e>>4)&0x0fff)-0x3fe; *q&=0x0f; *q|=0x3fe0;
*/ #endif
/* Equivalent C language standard library function: */ #ifdef UNK
x = frexp( x, &e ); #endif
#ifdef MIEEE
x = frexp( x, &e ); #endif
/* logarithm using log(x) = z + z**3 P(z)/Q(z), *wherez=2(x-1)/x+1)
*/
if( (e > 2) || (e < -2) )
{ if( x < SQRTH )
{ /* 2( 2x-1 )/( 2x+1 ) */
e -= 1;
z = x - 0.5;
y = 0.5 * z + 0.5;
} else
{ /* 2 (x-1)/(x+1) */
z = x - 0.5;
z -= 0.5;
y = 0.5 * x + 0.5;
}
x = z / y;
/* rational form */
z = x*x;
z = x * ( z * polevl( z, R, 2 ) / p1evl( z, S, 3 ) );
y = e;
z = z - y * 2.121944400546905827679e-4;
z = z + x;
z = z + e * 0.693359375; goto ldone;
}
/* logarithm using log(1+x) = x - .5x**2 + x**3 P(x)/Q(x) */
if( x < SQRTH )
{
e -= 1;
x = ldexp( x, 1 ) - 1.0; /* 2x - 1 */
} else
{
x = x - 1.0;
}
/* rational form */
z = x*x; #if DEC
y = x * ( z * polevl( x, P, 5 ) / p1evl( x, Q, 6 ) ); #else
y = x * ( z * polevl( x, P, 5 ) / p1evl( x, Q, 5 ) ); #endif if( e )
y = y - e * 2.121944400546905827679e-4;
y = y - ldexp( z, -1 ); /* y - 0.5 * z */
z = x + y; if( e )
z = z + e * 0.693359375;
ldone:
return( z );
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet am 2026-06-19)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.