/* fltest.c * Test program for floor(), frexp(), ldexp()
*/
/* Cephes Math Library Release 2.1: December, 1988 Copyright 1984, 1987, 1988 by Stephen L. Moshier (moshier@world.std.com)
*/
/*#include "mconf.h"*/ #define MACHEPL 5.42101086242752217003726400434970855712890625E-20L #define N 16300
void flierr(); int printf(); voidexit();
int
main()
{ longdouble x, y, y0, z, f, x00, y00; int i, j, e, e0; int errfr, errld, errfl, underexp, err, errth, e00; longdouble frexpl(), ldexpl(), floorl();
f = 1.0L/MACHEPL;
x00 = 1.0L; for( j=0; j<57; j++ )
{
x = x00 - 1.0L; for( i=0; i<128; i++ )
{
y = floorl(x); if( y != x )
{
flierr( x, y, j );
errfl += 1;
} /* Warning! the if() statement is compiler dependent, * since x-0.49 may be held in extra precision accumulator * so would never compare equal to x! The subroutine call * y = floor() forces z to be stored as a double and reloaded * for the if() statement.
*/
z = x - 0.49L;
y = floorl(z); if( z == x ) break; if( y != (x - 1.0L) )
{
flierr( z, y, j );
errfl += 1;
}
z = x + 0.49L;
y = floorl(z); if( z != x )
{ if( y != x )
{
flierr( z, y, j );
errfl += 1;
}
}
x = -x;
y = floorl(x); if( z != x )
{ if( y != x )
{
flierr( x, y, j );
errfl += 1;
}
}
z = x + 0.49L;
y = floorl(z); if( z != x )
{ if( y != x )
{
flierr( z, y, j );
errfl += 1;
}
}
z = x - 0.49L;
y = floorl(z); if( z != x )
{ if( y != (x - 1.0L) )
{
flierr( z, y, j );
errfl += 1;
}
}
x = -x;
x += 1.0L;
}
x00 = x00 + x00;
}
y = floorl(0.0L); if( y != 0.0L )
{
flierr( 0.0L, y, 57 );
errfl += 1;
}
y = floorl(-0.0L); if( y != 0.0L )
{
flierr( -0.0L, y, 58 );
errfl += 1;
}
y = floorl(-1.0L); if( y != -1.0L )
{
flierr( -1.0L, y, 59 );
errfl += 1;
}
y = floorl(-0.1L); if( y != -1.0l )
{
flierr( -0.1L, y, 60 );
errfl += 1;
}
if( errfl == 0 )
printf( "No errors found in floorl().\n" ); exit(0); return 0;
}
void flierr( x, y, k ) longdouble x, y; int k;
{
printf( "Test %d: ", k+1 );
printf( "floorl(%.15Le) =?= %.15Le\n", x, y );
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
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.