#define F W #define Fa Wa #define Fb Wb #define G W #define Ga Wa #define Gb u #define H W #define Ha Wb #define Hb Wb
#ifdef ANSIC float floorf( float ); float frexpf( float, int *); float ldexpf( float, int ); float powif( float, int ); #else float floorf(), frexpf(), ldexpf(), powif(); #endif
/* Find a multiple of 1/16 that is within 1/16 of x. */ #define reduc(x) 0.0625 * floorf( 16 * (x) )
#ifdef ANSIC float powf( float x, float y ) #else float powf( x, y ) float x, y; #endif
{ float u, w, z, W, Wa, Wb, ya, yb; /* float F, Fa, Fb, G, Ga, Gb, H, Ha, Hb */ int e, i, nflg;
nflg = 0; /* flag = 1 if x<0 raised to integer power */
w = floorf(y); if( w < 0 )
z = -w; else
z = w; if( (w == y) && (z < 32768.0) )
{
i = w;
w = powif( x, i ); return( w );
}
if( x <= 0.0F )
{ if( x == 0.0 )
{ if( y == 0.0 ) return( 1.0 ); /* 0**0 */ else return( 0.0 ); /* 0**y */
} else
{ if( w != y )
{ /* noninteger power of negative number */
mtherr( fname, DOMAIN ); return(0.0);
}
nflg = 1; if( x < 0 )
x = -x;
}
}
/* separate significand from exponent */
x = frexpf( x, &e );
/* find significand in antilog table A[] */
i = 1; if( x <= A[9] )
i = 9; if( x <= A[i+4] )
i += 4; if( x <= A[i+2] )
i += 2; if( x >= A[1] )
i = -1;
i += 1;
/* Find (x - A[i])/A[i] *inordertocomputelog(x/A[i]): * *log(x)=log(ax/a)=log(a)+log(x/a) * *log(x/a)=log(1+v),v=x/a-1=(x-a)/a
*/
x -= A[i];
x -= B[ i >> 1 ];
x *= Ainv[i];
/* rational approximation for log(1+v): * *log(1+v)=v-0.5v^2+v^3P(v) *Theoreticalrelativeerroroftheapproximationis3.5e-11 *ontheinterval2^(1/16)-1>v>2^(-1/16)-1
*/
z = x*x;
w = (((-0.1663883081054895 * x
+ 0.2003770364206271) * x
- 0.2500006373383951) * x
+ 0.3333331095506474) * x * z;
w -= 0.5 * z;
/* Convert to base 2 logarithm: *multiplybylog2(e)
*/
w = w + LOG2EA * w; /* Note x was not yet added in *toaboverationalapproximation, *sodoitnow,whilemultiplying *bylog2(e).
*/
z = w + LOG2EA * x;
z = z + x;
/* Compute exponent term of the base 2 logarithm. */
w = -i;
w *= 0.0625; /* divide by 16 */
w += e; /* Now base 2 log of x is w + z. */
/* Multiply base 2 log by y, in extended precision. */
/* separate y into large part ya *andsmallpartyblessthan1/16
*/
ya = reduc(y);
yb = y - ya;
F = z * y + w * yb;
Fa = reduc(F);
Fb = F - Fa;
G = Fa + w * ya;
Ga = reduc(G);
Gb = G - Ga;
H = Fb + Gb;
Ha = reduc(H);
w = 16 * (Ga + Ha);
/* Test the power of 2 for overflow */ if( w > MEXP )
{
mtherr( fname, OVERFLOW ); return( MAXNUMF );
}
/* Now the product y * log2(x) = Hb + e/16.0. * *Computebase2exponentialofHb, *where-0.0625<=Hb<=0. *Theoreticalrelativeerroroftheapproximationis2.8e-12.
*/ /* z = 2**Hb - 1 */
z = ((( 9.416993633606397E-003 * Hb
+ 5.549356188719141E-002) * Hb
+ 2.402262883964191E-001) * Hb
+ 6.931471791490764E-001) * Hb;
/* Express e/16 as an integer plus a negative number of 16ths. *Findlookuptableentryforthefractionalpowerof2.
*/ if( e < 0 )
i = -( -e >> 4 ); else
i = (e >> 4) + 1;
e = (i << 4) - e;
w = A[e];
z = w + w * z; /* 2**-e * ( 1 + (2**Hb-1) ) */
z = ldexpf( z, i ); /* multiply by integer power of 2 */
if( nflg )
{ /* For negative x, *findoutiftheintegerexponent *isoddoreven.
*/
w = 2 * floorf( (float) 0.5 * w ); if( w != y )
z = -z; /* odd exponent */
}
return( z );
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-06-27)
¤
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.