/* Single precision circular sine *testinterval:[-pi/4,+pi/4] *trials:10000 *peakrelativeerror:6.8e-8 *rmsrelativeerror:2.6e-8
*/ #include"mconf.h"
staticfloat FOPI = 1.27323954473516;
externfloat PIO4F; /* Note, these constants are for a 32-bit significand: */ /* staticfloatDP1=0.7853851318359375; staticfloatDP2=1.30315311253070831298828125e-5; staticfloatDP3=3.03855025325309630e-11; staticfloatlossth=65536.;
*/
/* These are for a 24-bit significand: */ staticfloat DP1 = 0.78515625; staticfloat DP2 = 2.4187564849853515625e-4; staticfloat DP3 = 3.77489497744594108e-8; staticfloat lossth = 8192.; staticfloat T24M1 = 16777215.;
sign = 1;
x = xx; if( xx < 0 )
{
sign = -1;
x = -xx;
} if( x > T24M1 )
{
mtherr( "sinf", TLOSS ); return(0.0);
}
j = FOPI * x; /* integer part of x/(PI/4) */
y = j; /* map zeros to origin */ if( j & 1 )
{
j += 1;
y += 1.0;
}
j &= 7; /* octant modulo 360 degrees */ /* reflect in x axis */ if( j > 3)
{
sign = -sign;
j -= 4;
}
if( x > lossth )
{
mtherr( "sinf", PLOSS );
x = x - y * PIO4F;
} else
{ /* Extended precision modular arithmetic */
x = ((x - y * DP1) - y * DP2) - y * DP3;
} /*einits();*/
z = x * x; if( (j==1) || (j==2) )
{ /* measured relative error in +/- pi/4 is 7.8e-8 */ /* y=((2.443315711809948E-005*z -1.388731625493765E-003)*z +4.166664568298827E-002)*z*z;
*/
p = coscof;
y = *p++;
y = y * z + *p++;
y = y * z + *p++;
y *= z * z;
y -= 0.5 * z;
y += 1.0;
} else
{ /* Theoretical relative error = 3.8e-9 in [-pi/4, +pi/4] */ /* y=((-1.9515295891E-4*z +8.3321608736E-3)*z -1.6666654611E-1)*z*x; y+=x;
*/
p = sincof;
y = *p++;
y = y * z + *p++;
y = y * z + *p++;
y *= z * x;
y += x;
} /*einitd();*/ if(sign < 0)
y = -y; return( y);
}
/* Single precision circular cosine *testinterval:[-pi/4,+pi/4] *trials:10000 *peakrelativeerror:8.3e-8 *rmsrelativeerror:2.2e-8
*/
#ifdef ANSIC float cosf( float xx ) #else float cosf(xx) double xx; #endif
{ float x, y, z; int j, sign;
/* make argument positive */
sign = 1;
x = xx; if( x < 0 )
x = -x;
j = FOPI * x; /* integer part of x/PIO4 */
y = j; /* integer and fractional part modulo one octant */ if( j & 1 ) /* map zeros to origin */
{
j += 1;
y += 1.0;
}
j &= 7; if( j > 3)
{
j -=4;
sign = -sign;
}
if( j > 1 )
sign = -sign;
if( x > lossth )
{
mtherr( "cosf", PLOSS );
x = x - y * PIO4F;
} else /* Extended precision modular arithmetic */
x = ((x - y * DP1) - y * DP2) - y * DP3;
z = x * x;
if( (j==1) || (j==2) )
{
y = (((-1.9515295891E-4 * z
+ 8.3321608736E-3) * z
- 1.6666654611E-1) * z * x)
+ x;
} else
{
y = (( 2.443315711809948E-005 * z
- 1.388731625493765E-003) * z
+ 4.166664568298827E-002) * z * z;
y -= 0.5 * z;
y += 1.0;
} if(sign < 0)
y = -y; return( y );
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet am 2026-06-25)
¤
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.