diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-05-10 00:40:28 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-05-10 00:40:28 +0000 |
commit | 1077fa4d772832f77a677ce7fb7c2d513b959e3f (patch) | |
tree | 579bee13fb0b58d2800206366ec2caecbb15f3fc /libm/ldouble/flrtstl.c | |
parent | 22358dd7ce7bb49792204b698f01a6f69b9c8e08 (diff) |
uClibc now has a math library. muahahahaha!
-Erik
Diffstat (limited to 'libm/ldouble/flrtstl.c')
-rw-r--r-- | libm/ldouble/flrtstl.c | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/libm/ldouble/flrtstl.c b/libm/ldouble/flrtstl.c new file mode 100644 index 000000000..77a389324 --- /dev/null +++ b/libm/ldouble/flrtstl.c @@ -0,0 +1,104 @@ +long double floorl(), ldexpl(), frexpl(); + +#define N 16382 +void prnum(); +int printf(); +void exit(); + +void main() +{ +long double x, f, y, last, z, z0, y1; +int i, k, e, e0, errs; + +errs = 0; +f = 0.1L; +x = f; +last = x; +z0 = frexpl( x, &e0 ); +printf( "frexpl(%.2Le) = %.5Le, %d\n", x, z0, e0 ); +k = 0; +for( i=0; i<N+5; i++ ) + { + y = ldexpl( f, k ); + if( y != x ) + { + printf( "ldexpl(%.1Le, %d) = %.5Le, s.b. %.5Le\n", + f, k, y, x ); + ++errs; + } + z = frexpl( y, &e ); + if( (e != k+e0) || (z != z0) ) + { + printf( "frexpl(%.1Le) = %.5Le, %d; s.b. %.5Le, %d\n", + y, z, e, z0, k+e0 ); + ++errs; + } + x += x; + if( x == last ) + break; + last = x; + k += 1; + } +printf( "i = %d\n", k ); +prnum( "last y =", &y ); +printf("\n"); + +f = 0.1L; +x = f; +last = x; +k = 0; +for( i=0; i<N+64; i++ ) + { + y = ldexpl( f, k ); + if( y != x ) + { + printf( "ldexpl(%.1Le, %d) = %.5Le, s.b. %.5Le\n", + f, k, y, x ); + ++errs; + } + z = frexpl( y, &e ); + if( +#if 1 + (e > -N+1) && +#endif + ((e != k+e0) || (z != z0)) ) + { + printf( "frexpl(%.1Le) = %.5Le, %d; s.b. %.5Le, %d\n", + y, z, e, z0, k+e0 ); + ++errs; + } + y1 = ldexpl( z, e ); + if( y1 != y ) + { + printf( "ldexpl(%.1Le, %d) = %.5Le, s.b. %.5Le\n", + z, e, y1, y ); + ++errs; + } + + x *= 0.5L; + if( x == 0.0L ) + break; + if( x == last ) + break; + last = x; + k -= 1; + } +printf( "i = %d\n", k ); +prnum( "last y =", &y ); + +printf( "\n%d errors\n", errs ); +exit(0); +} + + +void prnum(str, x) +char *str; +unsigned short *x; +{ +int i; + +printf( "%s ", str ); +printf( "%.5Le = ", *(long double *)x ); +for( i=0; i<5; i++ ) + printf( "%04x ", *x++ ); +} |